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

Logic using at new stmt

Former Member
0 Likes
611

Hi,

In my scenario have to write a code with the following logic.

consider in the internal table have the values of vendor,docu num ,buzei and amt.

my logic is if the 1st vendor comes in the loop have to count the line items and check for some codn next thing is check for 2nd vendor.Have written the coding as

LOOP AT gt_bsik.

wa_bsik = gt_bsik.

AT NEW lifnr.

w_sum = 0.

LOOP AT gt_bsik INTO wa_bsik.

w_sum = w_sum + wa_bsik-buzei.

endat.

AT END OF lifnr.

APPEND lt_vendors.

APPEND gt_bsik_copy.

ENDAT.

IF w_sum > 200.

DELETE gt_bsik WHERE lifnr =

gt_bsik_copy-lifnr .

ENDIF.

In the above mentioned code when 1st vendor comes its checking for the 1st docu numbe line items alone.Its not checking for 2 nd docu num.I have

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
592

Hello Saranya,

You need to change the logic:


LOOP AT gt_bsik.
wa_bsik = gt_bsik.
AT NEW lifnr.

w_sum = 0.
* LOOP AT gt_bsik INTO wa_bsik.
* w_sum = w_sum + wa_bsik-buzei.
ENDAT.

w_sum = w_sum + gt_bsik-buzei.

AT END OF lifnr.
APPEND lt_vendors.
APPEND gt_bsik_copy.
ENDAT.

IF w_sum > 200.
DELETE gt_bsik WHERE lifnr =
gt_bsik_copy-lifnr .
ENDIF.

BR,

Suhas

Hi,

In my scenario have to write a code with the following logic.

consider in the internal table have the values of vendor,docu num ,buzei and amt.

my logic is if the 1st vendor comes in the loop have to count the line items and check for some codn next thing is check for 2nd vendor.Have written the coding as

LOOP AT gt_bsik.

wa_bsik = gt_bsik.

AT NEW lifnr.

w_sum = 0.

LOOP AT gt_bsik INTO wa_bsik.

w_sum = w_sum + wa_bsik-buzei.

endat.

AT END OF lifnr.

APPEND lt_vendors.

APPEND gt_bsik_copy.

ENDAT.

IF w_sum > 200.

DELETE gt_bsik WHERE lifnr =

gt_bsik_copy-lifnr .

ENDIF.

In the above mentioned code when 1st vendor comes its checking for the 1st docu numbe line items alone.Its not checking for 2 nd docu num.I have

3 REPLIES 3
Read only

GauthamV
Active Contributor
0 Likes
592

Use clear statement in loop.

Read only

Former Member
0 Likes
592

Hi,

In my understanding u can achieve ur requirements like this.


gt_bsik1[] = gt_bsik.

Loop at gt_bsik into wa_bsik.

Loop at gt_bsik1 into wa_bsik1 where lifnr = wa_bsik-lifnr.

"do  ur codings as per ur requirement

Endloop.
Endloop.

Thanks.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
593

Hello Saranya,

You need to change the logic:


LOOP AT gt_bsik.
wa_bsik = gt_bsik.
AT NEW lifnr.

w_sum = 0.
* LOOP AT gt_bsik INTO wa_bsik.
* w_sum = w_sum + wa_bsik-buzei.
ENDAT.

w_sum = w_sum + gt_bsik-buzei.

AT END OF lifnr.
APPEND lt_vendors.
APPEND gt_bsik_copy.
ENDAT.

IF w_sum > 200.
DELETE gt_bsik WHERE lifnr =
gt_bsik_copy-lifnr .
ENDIF.

BR,

Suhas