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

Code Doubt

Former Member
0 Likes
763

Hi ,

Tell me for each statement how does the Following Code Work ....

That too Loop at ***** Into ***** i need explanation ( What it will pass into other )



LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT
WHERE FIELDNM = 'ERSDA'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_ERSDA.
APPEND L_R_ERSDA.
ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
737

Hi,

LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT.

<b>This loop will select t_select from the s_s_if table into the workarea l_s_select where the condition statisfies.</b>

WHERE FIELDNM = 'ERSDA'.

MOVE-CORRESPONDING L_S_SELECT TO L_R_ERSDA.

<b>Move the entries in the l_s_select into a table with the same field.</b>

APPEND L_R_ERSDA.

<b>Appending the entries into the table.</b>

ENDLOOP.

Can u give the declaration for l_s_select and s_s_if.

7 REPLIES 7
Read only

Former Member
0 Likes
737

Hello Kumar ,

The loop at into where , this will loop at all those records where the feildnm =ERSDA , for all other records the loop does iterate.

Move corresponding , moves the value from feilds of L_S_SELECT to the corresponding feilds of L_R_ERSDA , so in this the structures must hev feils with same name.

append appends the value of the header into the internal table.

Regards

Arun

Read only

anversha_s
Active Contributor
0 Likes
737

hi,

LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT
WHERE FIELDNM = 'ERSDA'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_ERSDA.
APPEND L_R_ERSDA.
ENDLOOP.

1. fetch the records satsfying the condition 'ERSDA' and will place it in the work area L_S_SELECT.

2. Move-Corresponding will move the ciorresponding field name from L_S_SELECT TO L_R_ERSDA(this is header line).

3. that header line is appended into the itab L_R_ERSDA

Regards

Anver

Read only

Former Member
0 Likes
737

Hi ,

So it Loops based on Field name 'ERSDA' and select the Fields and Appends those Records to Body ...Right ?

Read only

0 Likes
737

hi,

ya it will move the record based on Field name 'ERSDA' into the work area .

Regards

Anver

Read only

Former Member
0 Likes
737

Hi,

LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT

WHERE FIELDNM = 'ERSDA' ......

This will copy the content of ur internal table S_S_IF-T_SELECT to work area L_S_SELECT line by line,where WHERE FIELDNM = 'ERSDA'

MOVE-CORRESPONDING L_S_SELECT TO L_R_ERSDA

Once the record is found in internal table satisfying above 'Where' condition..it will copy the content from work area L_S_SELECT to internal table L_R_ERSDA's header.. (corresponding fields)

..

APPEND L_R_ERSDA.

This will append the record ( with corresponding field copied ) to internal table L_R_ERSDA

ENDLOOP.

Read only

Former Member
0 Likes
738

Hi,

LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT.

<b>This loop will select t_select from the s_s_if table into the workarea l_s_select where the condition statisfies.</b>

WHERE FIELDNM = 'ERSDA'.

MOVE-CORRESPONDING L_S_SELECT TO L_R_ERSDA.

<b>Move the entries in the l_s_select into a table with the same field.</b>

APPEND L_R_ERSDA.

<b>Appending the entries into the table.</b>

ENDLOOP.

Can u give the declaration for l_s_select and s_s_if.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
737

Hi,

S_S_IF is an internal table which in turn should contain an internal table called t_select.

Basically,the code is looping the internal table t_select if the field fieldnam = 'ERSDA'.

For each record satisfying the condition,it is placing the record in work area l_s_select.

And then inside the loop,it's moving the similar field of work area l_s_select to l_r_ersda.

After moving the correspodning values,it is appending the values to the internal table l_r_ersda from the work area l_r_ersda.