3 weeks ago - last edited 3 weeks ago
hello All,
I am looking for some help in understanding the concept of for loop.
I am using a for loop where i am read the value from table if the value is not present then i want to take from other table
old code
LOOP AT IT_VBRK_VBRP ASSIGNING <WA_VBRK_VBRP>.
CLEAR: WA_VBKD_A.
READ TABLE I_VBKD_A INTO WA_VBKD_A WITH KEY VBELN = <WA_VBRK_VBRP>-AUBEL
POSNR = <WA_VBRK_VBRP>-AUPOS .
IF SY-SUBRC <> 0.
READ TABLE I_VBKD_A INTO WA_VBKD_A WITH KEY VBELN = <WA_VBRK_VBRP>-AUBEL
POSNR = '000000'.
IF SY-SUBRC = 0.
<WA_VBRK_VBRP>-BSTKD = WA_VBKD_A-BSTKD.
ENDIF.
ELSE.
<WA_VBRK_VBRP>-BSTKD = WA_VBKD_A-BSTKD.
ENDIF.
endloop.
New code which i want to optimize
IT_VBRK_VBRP_1[] = VALUE #( FOR <WA_VBRK_VBRP> IN IT_VBRK_VBRP[] (
BSTKD = COND #( LET WA_VBKD_A = VALUE #( I_VBKD_A[ VBELN = <WA_VBRK_VBRP>-AUBEL
POSNR = <WA_VBRK_VBRP>-AUPOS ] ) IN
WHEN WA_VBKD_A IS NOT INITIAL
THEN WA_VBKD_A-BSTKD
ELSE I_VBKD_A[ VBELN = <WA_VBRK_VBRP>-AUBEL
POSNR = '00000' ]-BSTKD ) ) ) .
For Above code i am getting dump ITAB_LINE_NOT_FOUND even though the line is there so i need to know how to handle if the line does not exists.
Request clarification before answering.
@Sandra_Rossi I have done some R&D and found the solution to make code work according to requirement
IT_VBRK_VBRP_1[] = VALUE #( FOR <WA_VBRK_VBRP> IN IT_VBRK_VBRP[] (
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
BSTKD = COND #( LET WA_VBKD_A = VALUE #( I_VBKD_A[ VBELN = <WA_VBRK_VBRP>-AUBEL
POSNR = <WA_VBRK_VBRP>-AUPOS ] OPTIONAL )
WA_FALLBACK = VALUE #( I_vbkd_a[ VBELN = <WA_VBRK_VBRP>-AUBEL
POSNR = '000000' ] OPTIONAL ) IN
WHEN WA_VBKD_A IS NOT INITIAL
THEN WA_VBKD_A-BSTKD
ELSE WA_FALLBACK-BSTKD )
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
) ) .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
22 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.