Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

basic abap report queries

Former Member
0 Likes
762

IF sy-subrc IS INITIAL.

LOOP AT gi_afko INTO gwa_afko.

READ TABLE gi_mara INTO gwa_mara WITH KEY matnr = gwa_afko-plnbez.

IF sy-subrc IS INITIAL.

MOVE gwa_mara-mtart TO gwa_output-mtart.

MOVE gwa_mara-pstat TO gwa_output-pstat.

MOVE gwa_afko-aufnr TO gwa_output-aufnr.

MOVE gwa_afko-gamng TO gwa_output-gamng.

APPEND gwa_output TO gi_output.

ENDIF.

ENDLOOP.

ENDIF.

=======================================

I am novice in ABAP. Please help me to understand the above coding portion.

Q. 1. Why sy-subrc IS INITIAL is checked before loop at....into wa... statement. If it is not checked there, what problem will occur?

Q.2. What does 'LOOP AT gi_afko INTO gwa_afko' statement mean?Does it mean that data of internal table

of afko being shifted to it's work area with each and every loop pass?What is the exact definition of internal table and work area? internal table is a temporary storage i think and what is work area?or what's the relationship between internal table and work area.

Q.3. what i've understood from the above coding portion that is data being read from internal table of mara to it's work area for the condition

matnr = gwa_afko-plnbez and then again 'sy-subrc is initial'

is being checked. If sy-subrc is not checked here, what problem will occur?

Q.4. What's the meaning of the statement

'APPEND gwa_output TO gi_output'?

Please help me to understand.

Thanks a lot.

5 REPLIES 5
Read only

Former Member
0 Likes
722

1. There might be some select/some statement to get the data before

that and sy-subrc is being checked if it succeeds ..

If the above statement is true then only gi_output will get the values ..

2. Exactly. Internal table is being shifted to its work area one record at

a time in the loop..

3. If sy-subrc = 0 .. i.e. if there is an entry then only gi_output will be

appended.(i.e. gwa_mara will be filled in the read statement ).

if sy-subrc <> 0 the U might be populating the same values from

gwa_output into gi_output.

4. 'APPEND gwa_output TO gi_output'? ..

Inserts data in the work area gwa_output to the internal table gi_output

Read only

Former Member
0 Likes
722

Hi Cinthia,

Ans 1 : Sy-Subrc is INITIAL means ,

The Value of sy-subrc is 0. If it is 0 the condition is satisfied and then it executes your LOOP AT statement

Ans 2 : While looping at gi_afko it moves one record into gwa_afko.

gwa_afko will consist only a single record at an instant of time and gi_afko will consist of a collection of records.

Ans 3 : If this condition is not Initial the MOVE stmts will not get executed.

Ans 4 : The Record in gwa_output will be added to the Internal Table gi_output.

Please let me know if you need any further info.

Regards,

Sai

Read only

Former Member
0 Likes
722

hi,

if sy-subrc is initial means sy-subrc = 0

it depends upon pervious functions performed .this indicates that previous function is succesfull

if u dnt specfiy the sy-subrc = 0 .u cannot catch the errors

2.

even ever you are writting or reading the data from internal table that is donr only through work area only

work area will hold only one record at a time and interna; table will hold n number of records

both internal table as well as work area are temporary storage location only at the run time only memory will be allocated

3

if the table is read successful then only move operation is performed

4

as work area consists of only one records to make the record inserted into table use append statement

Edited by: Nandini P on Feb 20, 2008 12:04 PM

Read only

0 Likes
722

you are more worried about sy-subrc right

now suppose in the first loop pass the value that we want exist in the internal table and the corresponding values are passed on to the work area.in second loop pass if the required condition doesnot match then in the header of the table the previous data still exists coz you are not clearing it then the same data will be transferred one more time .

thats the reason we use sy-subrc so that only that get we get that sataisfies our condition.

hope it will make it more clear rest all every body has cleared ur rest of ur doubts

Read only

0 Likes
722

you are more worried about sy-subrc right

now suppose in the first loop pass the value that we want exist in the internal table and the corresponding values are passed on to the work area.in second loop pass if the required condition doesnot match then in the header of the table the previous data still exists coz you are not clearing it then the same data will be transferred one more time .

thats the reason we use sy-subrc so that only that get we get that sataisfies our condition.

hope it will make it more clear rest all every body has cleared ur rest of ur doubts