2023 Mar 03 2:54 PM
Hi, I have a loop within a loop and I'm having problems in which the value of LFS_IT_LIPS is always constant because of the EXIT. Is there a way that when the condition inside the it_lips is met it will exit the loop but the LFS_IT_LIPS-VBELN will be refreshed? Because the LFS_IT_LIPS-VBELN is always at 800000123. I'm assuming that it will change.
LOOP AT it_vbap ASSIGNING FIELD-SYMBOLS (<lfs_it_vbap>).
LOOP AT it_lips ASSIGNING FIELD-SYMBOLS(<lfs_it_lips>).
"Conditions here
EXIT.
ENDLOOP.
ENDLOOP.
2023 Mar 03 3:04 PM
Since you didn't put a WHERE condition in the inner loop, I assume you should use a CONTINUE (next record) and not an EXIT (exit loop).
It seems that you are actually always reading the first record of the delivery items and immediately exiting the inner loop at each sales order item?
But you haven't provided enough information to be sure of your requirement, could you elaborate?
2023 Mar 07 2:09 AM
raymond.giuseppi
Here's the code:
Internal tables that were populated via Select SQL statement:
it_vbap
-entries 12345, 12346, 12347, 12348
it_lips
-entries 9870, 0971, 0982
it_item_stock
it_for_delivery
-entries has both
LOOP AT it_vbap ASSIGNING FIELD-SYMBOL(<lfs_it_vbap>).
LOOP AT it_lips ASSINING FIELD-SYMBOL(<lfs_it_lips>).
****The logic inside the loop checks if the <LFS_IT_VBAP>-VBELN is in it_item_stock
****If yes, it should check if the <LFS_IT_LIPS>-VBELN is in it_for_delivery.
****When successfully checked, it should check for another pair of Sales Document and Delivery Document.
****Current situation: Sales Document 12345 has been checked, then the loop will proceed to check for delivery document 9870.
****However, upon checking the delivery document 9870 and sales doc 12345, only the value of LFS_IT_LIPS-VBELN will change.
****I was expecting that the loop will check the pair of sales doc of 12346 and delivery doc of 0971.
ENDLOOP.
ENDLOOP.
2023 Mar 07 6:42 AM
the two loop are independent, the inner loop will read from 1st to last record of internal table.
2023 Mar 03 3:32 PM
I'm fairly sure that we've pointed out the use of the "code" button in the question editor.
Try to use it.
2023 Mar 07 3:44 AM
Hi matthew.billingham thanks. I think my question is wrong as I'm looking on how to improve my code.
I want to loop LFS_IT_VBAP and LFS_IT_LIPS at the same time. Is it possible?
it_vbap
-entries 12345, 12346, 12347, 12348
it_lips
-entries 9870, 0971, 0982
it_item_stock
it_for_delivery
-entries has both
LOOP AT it_vbap ASSIGNING FIELD-SYMBOL(<lfs_it_vbap>).
LOOP AT it_lips ASSINING FIELD-SYMBOL(<lfs_it_lips>).
****The logic inside the loop checks if the <LFS_IT_VBAP>-VBELN is in it_item_stock
****If yes, it should check if the <LFS_IT_LIPS>-VBELN is in it_for_delivery.
****When successfully checked, it should check for another pair of Sales Document and Delivery Document.
****Current situation: Sales Document 12345 has been checked, then the loop will proceed to check for delivery document 9870.
****However, upon checking the delivery document 9870 and sales doc 12345, only the value of LFS_IT_LIPS-VBELN will change.
****I was expecting that the loop will check the pair of sales doc of 12346 and delivery doc of 0971.
ENDLOOP.
ENDLOOP.