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

help with some ABAP code

Former Member
0 Likes
976

I am trying to fill the quantity value if it is blank by looking for a record with the key and putting it's value in it. the code is below but the part whee it says where order_qty > 0 is not working. It just hops out even if it is.

CLEAR: T_SCHED_DATA, T_QUANTITY_DATA.

REFRESH: T_SCHED_DATA, T_QUANTITY_DATA.

*

SELECT DOC_NUMBER S_ORD_ITEM SCHED_LINE DSDEL_DATE REQ_DATE ORDER_QTY

INTO TABLE T_SCHED_DATA

FROM /BIC/AZSCH_O5400

FOR ALL ENTRIES IN DATA_PACKAGE

WHERE

DOC_NUMBER = DATA_PACKAGE-DOC_NUMBER AND

S_ORD_ITEM = DATA_PACKAGE-S_ORD_ITEM AND

SCHED_LINE = DATA_PACKAGE-SCHED_LINE.

SELECT DOC_NUMBER S_ORD_ITEM SCHED_LINE DSDEL_DATE REQ_DATE ORDER_QTY

INTO TABLE T_QUANTITY_DATA

FROM /BIC/AZSCH_O5400

FOR ALL ENTRIES IN T_SCHED_DATA

WHERE

DOC_NUMBER = T_SCHED_DATA-VBELN AND

S_ORD_ITEM = T_SCHED_DATA-POSNR.

T_QUANTITY_DATA2[] = T_QUANTITY_DATA[].

sort t_quantity_data2 by vbeln posnr SCHED_LINE

ascending.

sort t_quantity_data by vbeln posnr SCHED_LINE

ascending.

loop at T_QUANTITY_DATA into LF_DATA

where order_qty > 0.

loop at T_QUANTITY_DATA2 into LF_DATA2

where

vbeln = LF_DATA-VBELN AND

posnr = LF_DATA-POSNR AND

DSDEL_DATE = LF_DATA-DSDEL_DATE AND

SCHED_LINE NE LF_DATA-SCHED_LINE and

order_qty = 0.

lf_data3 = lf_data2.

move LF_DATA-order_qty to lf_data3-order_qty.

append lf_data3 to T_QUANTITY_DATA3.

endloop.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
959

HI,

why dont you check with ur data... you say its going out of that loop.. do you think that this statment is not working.. There is not use in posting the same question again and again.. put a break point and check the data.. ur code is 100 correct...

Thanks

mahesh

10 REPLIES 10
Read only

Former Member
0 Likes
960

HI,

why dont you check with ur data... you say its going out of that loop.. do you think that this statment is not working.. There is not use in posting the same question again and again.. put a break point and check the data.. ur code is 100 correct...

Thanks

mahesh

Read only

0 Likes
959

We did and had another developer look at it and it is not working and doing the exact same thing

thanks for your help

Read only

Former Member
0 Likes
959

How is "order_qty" defined? It should be numeric type for your statement to work as expected.

Read only

0 Likes
959

Yes it is defined as numeric

Read only

0 Likes
959

Then it should work, put a breakpoint on the LOOP statement and see if there are any contents in the internal table. Also verify if you have any records with order_qty > 0.

Read only

0 Likes
959

See if your second loop is the one that is an issue, not the first loop.

Read only

0 Likes
959

loop at T_QUANTITY_DATA into LF_DATA

where <b>order_qty > 0.</b> <b> " when this is greater than zero</b>

loop at T_QUANTITY_DATA2 into LF_DATA2

where

vbeln = LF_DATA-VBELN AND

posnr = LF_DATA-POSNR AND

DSDEL_DATE = LF_DATA-DSDEL_DATE AND

SCHED_LINE NE LF_DATA-SCHED_LINE and

<b>order_qty = 0.</b> <b>" how can it be zero here</b>

lf_data3 = lf_data2.

move LF_DATA-order_qty to lf_data3-order_qty.

append lf_data3 to T_QUANTITY_DATA3.

endloop.

endloop.

Read only

0 Likes
959

It can be zero because we have several lines/document and only the qty is on 1 line so we want to fill the blanks with whatever line is not zero. the one loop looks at the one > 0 and finds a amtch based on the key with qty = o and we wnat to fill it with what is in lf_data-order_qty

Read only

0 Likes
959

its nothing to do with the logic... its only data problem... we cannot help it out..

Read only

0 Likes
959

I got it to work but now my last code I need to modify the current recod with the qty but it keeps appending to the table instead of going to that record and modifying.

loop at T_QUANTITY_DATA3[] into LF_DATA3.

read table T_QUANTITY_DATA4[] into lf_data4 with key

vbeln = LF_DATA3-VBELN

posnr = LF_DATA3-POSNR.

T_QUANTITY_DATA5 = T_QUANTITY_DATA3.

move lf_data4-order_qty to lf_data5-order_qty.

append lf_data5 to T_QUANTITY_DATA5.