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

LOOP in a Smartform

joan_ayala
Participant
0 Likes
999

Hi friends,

I have my loop:

The content of variable 'GT_N1VP_CV'  is for example:

Under the Loop node, I have 2 text elements. The second one will be printed always. But the first one, I want to print it only when there is a change of VDATE and VTIME (previous image).  That is, this text node should be printed for rows 1 and 2, but not for row 3 because it has the same values for VDATE and VTIME than row 2.

How could I do that?  Thank you very much!

Joan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
968

Hi Joan,

1. Declare two variables GV_VDATE and GV_TIME in the global data of the smartform.

2. Now in your loop, for the 1st text element, in its conditions tab, put as below.

     Fieldname                 Relation      Comparison Value

     GS_N1VP-VDATE      NE               GV_VDATE

     GS_N1VP-VTIME       NE               GV_VTIME

3. After this text element, insert program lines as below.

     GV_VDATE =      GS_N1VP-VDATE.

     GV_VTIME  =      GS_N1VP-VTIME.

So in every loop pass, we check the value of VDATE and VTIME values with the previous loop. If it is not equal to the current iteration, then only the text element gets printed.

After this check is done, we assign the value of VDATE and VTIME of the current iteration into GV_VDATE and GV_VTIME.

Hope it helps!

2 REPLIES 2
Read only

Former Member
0 Likes
968

Hi

Its better to add program line and pass the values to another internal table based on your requirement.

In this case, new table should have only two rows.

Now you can print new internal table.

Thanks

Gowrishankar

Read only

Former Member
0 Likes
969

Hi Joan,

1. Declare two variables GV_VDATE and GV_TIME in the global data of the smartform.

2. Now in your loop, for the 1st text element, in its conditions tab, put as below.

     Fieldname                 Relation      Comparison Value

     GS_N1VP-VDATE      NE               GV_VDATE

     GS_N1VP-VTIME       NE               GV_VTIME

3. After this text element, insert program lines as below.

     GV_VDATE =      GS_N1VP-VDATE.

     GV_VTIME  =      GS_N1VP-VTIME.

So in every loop pass, we check the value of VDATE and VTIME values with the previous loop. If it is not equal to the current iteration, then only the text element gets printed.

After this check is done, we assign the value of VDATE and VTIME of the current iteration into GV_VDATE and GV_VTIME.

Hope it helps!