Você está na página 1de 6

BC400 Lesson: Working with Structures

Exercise 6: Working with Structures


Exercise Objectives
AIter completing this exercise, you will be able to:
Use the $%$3 'HEXJJHU to trace the data Ilow and understand the
connections between processing blocks.
Use the ABAP statement MOVE-CORRESPONDING to assign values
between structures.
Business ExampIe
You have to examine a speciIied ABAP program to ascertain when and how
speciIic data is transported between certain structured data objects.
Task 1:
Execute a program in debugging mode
1. Start the program SAPBC400WBS_GETTING_STARTED. On the
selection screen, enter LH in the $LUOLQH Iield. In the command Iield, enter
/h and then choose Enter. Choose F8 to run the program. You are now
in debugging mode.
2. Check that all oI the data objects are set to the initial value. TransIer all oI
the data objects deIined in the program into the Iield view. Display the type
assignment and the contents oI the structure components.
Hint: Within the program, the TABLES sbc400_carrier
statement deIines a structure variable of the same name and
structure Ior the speciIied Dictionary structure SBC400CARRIER.
This unusual, non-intuitive type oI structure deIinition is only used
Ior screen programming. The program-internally deIined structure is
used as the data exchange interIace between the program and the
screen. For more inIormation, reIer to these exercises in the chapter
on screen programming.
3. Step through the program using the single-step Iunction.
&RQWLQXHG RQ QH[W SDJH
2006/Q2 2006 SAP AG. All rights reserved. 111




Unit 4: Basic ABAP Language EIements BC400
Task 2:
Analyze the Iield contents
1. Which Iields oI the structure WASCARR does the SELECT statement Iill?
What is the value oI system Iield SY-SUBRC aIter this statement?
2. Now observe how Iields are copied Irom the structure WASCARR to the
structure SBC400CARRIER. Which Iield values are copied?
3. The ABAP statement CALL SCREEN 100 processes screen 100. What
are the technical names oI the Iields on the screen?
4. On the screen, enter the appropriate values Ior the user name, date, and time,
and continue the program with Enter.
Which program-internal data objects are now output in the list?
What are their values?
&RQWLQXHG RQ QH[W SDJH
112 2006 SAP AG. All rights reserved. 2006/Q2




BC400 Lesson: Working with Structures
Task 3:
Trace the list structure
1. Now, observe how the WRITE statement constructs the list.
Hint: AIter you have executed the Iirst WRITE statement, an
additional button appears in the tool bar. You can use this new button
to display the list buIIer generated so Iar.
Task 4:
Set breakpoints and change Iield contents
1. Restart the program in Debugging mode. Set a breakpoint Ior each WRITE
statement.
Also set a watchpoint Ior structure WASCARR.
Continue the program by selecting &RQWLQXH, and check why the processing
oI the program is stopped in each case.
2. Restart the program in Debugging mode. Set a breakpoint Ior the
CALL SCREEN statement and execute the program until it reaches this
statement. Now, before processing the screen, assign a random name to the
program-internal Iield UNAME oI the SBC400_CARRIER structure.
Hint: Choose &KDQJH )LHOG &RQWHQW in the )LHOG 1DPHV area to
change the Iield value in the Debugger.
Now, let the system process the CALL SCREEN statement. What do you
see on the screen?
2006/Q2 2006 SAP AG. All rights reserved. 113




Unit 4: Basic ABAP Language EIements BC400
SoIution 6: Working with Structures
Task 1:
Execute a program in debugging mode
1. Start the program SAPBC400WBS_GETTING_STARTED. On the
selection screen, enter LH in the $LUOLQH Iield. In the command Iield, enter
/h and then choose Enter. Choose F8 to run the program. You are now
in debugging mode.
a) Carry out this step as described.
2. Check that all oI the data objects are set to the initial value. TransIer all oI
the data objects deIined in the program into the Iield view. Display the type
assignment and the contents oI the structure components.
Hint: Within the program, the TABLES sbc400_carrier
statement deIines a structure variable of the same name and
structure Ior the speciIied Dictionary structure SBC400CARRIER.
This unusual, non-intuitive type oI structure deIinition is only used
Ior screen programming. The program-internally deIined structure is
used as the data exchange interIace between the program and the
screen. For more inIormation, reIer to these exercises in the chapter
on screen programming.
a) Carry out this step as described in the training material.
3. Step through the program using the single-step Iunction.
a) Carry out this step as described in the training material.
Task 2:
Analyze the Iield contents
1. Which Iields oI the structure WASCARR does the SELECT statement Iill?
What is the value oI system Iield SY-SUBRC aIter this statement?
Answer: All, zero
2. Now observe how Iields are copied Irom the structure WASCARR to the
structure SBC400CARRIER. Which Iield values are copied?
Answer: Fields with the same name - thereIore, MANDT, CARRID,
CARRNAME, and CURRCODE.
&RQWLQXHG RQ QH[W SDJH
114 2006 SAP AG. All rights reserved. 2006/Q2




BC400 Lesson: Working with Structures
3. The ABAP statement CALL SCREEN 100 processes screen 100. What
are the technical names oI the Iields on the screen?
Answer:
SBC400CARRIER-CARRID
SBC400CARRIER-CARRNAME
SBC400CARRIER-CURRCODE
SBC400CARRIER-UNAME
SBC400CARRIER-UZEIT
SBC400CARRIER-DATUM
4. On the screen, enter the appropriate values Ior the user name, date, and time,
and continue the program with Enter.
Which program-internal data objects are now output in the list?
What are their values?
Answer: The Iields oI the program-internal structure SBC400CARRIER
are output.
Their values are those that were displayed or entered on the screen.
Task 3:
Trace the list structure
1. Now, observe how the WRITE statement constructs the list.
Hint: AIter you have executed the Iirst WRITE statement, an
additional button appears in the tool bar. You can use this new button
to display the list buIIer generated so Iar.
a) Carry out this step as described.
Task 4:
Set breakpoints and change Iield contents
1. Restart the program in Debugging mode. Set a breakpoint Ior each WRITE
statement.
Also set a watchpoint Ior structure WASCARR.
&RQWLQXHG RQ QH[W SDJH
2006/Q2 2006 SAP AG. All rights reserved. 115




Unit 4: Basic ABAP Language EIements BC400
Continue the program by selecting &RQWLQXH, and check why the processing
oI the program is stopped in each case.
a) Choose %UHDNSRLQWV %UHDNSRLQW IRU 6WDWHPHQW to set a
breakpoint reIerring to a statement name. Enter WRITE in the dialog
box.
b) In the dialog box, enter structure name WASCARR to create a
watchpoint.
c) The processing oI the program is stopped at each breakpoint and
whenever a watchpoint is triggered.
2. Restart the program in Debugging mode. Set a breakpoint Ior the
CALL SCREEN statement and execute the program until it reaches this
statement. Now, before processing the screen, assign a random name to the
program-internal Iield UNAME oI the SBC400_CARRIER structure.
Hint: Choose &KDQJH )LHOG &RQWHQW in the )LHOG 1DPHV area to
change the Iield value in the Debugger.
Now, let the system process the CALL SCREEN statement. What do you
see on the screen?
a) Carry out this step as described.
b) On the screen, in the 8VHU Iield, you can see the name that was
previously speciIied in the Debugger. For more inIormation on the Iield
transport between the screen and the program, reIer to the appropriate
chapter.
116 2006 SAP AG. All rights reserved. 2006/Q2

Você também pode gostar