‎2009 May 24 8:47 AM
clear i_final1.
refresh i_final1.
if i_final[] is not initial.
loop at i_final.
*if i_final-augbl eq space* .
loop at i_final1.
i_final1-mblnr = i_final-mblnr.
i_final1-mjahr = i_final-mjahr.
i_final1-budat = i_final-budat.
i_final1-xblnr = i_final-xblnr.
i_final1-bldat = i_final-bldat.
i_final1-frbnr = i_final-frbnr.
i_final1-bktxt = i_final-bktxt.
i_final1-lifnr = i_final-lifnr.
i_final1-name = i_final-name.
i_final1-matnr = i_final-matnr.
i_final1-maktx = i_final-maktx.
i_final1-ebeln = i_final-ebeln.
i_final1-aedat = i_final-aedat.
i_final1-belnr = i_final-gjahr.
endloop.
endif.
endloop.
endif.I want to copy from one internal table to other internal table if a field is blank i tried using NULL and ' '
but both of them are not working can anyone help me out.
Edited by: Matt on May 24, 2009 1:38 PM - added tags
‎2009 May 24 12:50 PM
Hi,
I think couple thinks should be clarified here:
1) Are i_final and i_final1 of the same structure? If so, there should be not explicit addressing of components used, instead you should use move-corresponding or even better use i_final[ ] = i_fnal1[ ]
2) as explained by all posters above to check if i_final-augbl holds some value use either if it is initial or eq space (if this is character type field)
3) you are clearing i_final1 (content + header) at the beginning, so why do you loop at i_final1 later. It's empty there, that's why you can't append any entry to it. Processing simply never goes inside that, so no fields are moved to i_final1.
Considering above this is how the code should look like:
"emty your destination table
clear i_final1.
refresh i_final1.
"now move content from source table to your destination table
if i_final[] is not initial.
loop at i_final. "loop at source table
if i_final-augbl is initial. "or eq space if character type
move-corresponding i_final to i_final1. "if structures differ a bit, but most components are same
append i_final1.
endif.
endloop.
endif.
"another solution
"if structures are excatly the same and AUGBL is a key field
if i_final[] is not initial.
i_final[] = i_final1[]. "copy entire content
endif.
"now delete those record which stay empty at field AUGBL
delete table i_final1 with key AUGBL = space. "augbl must be a key field
Regards
Marcin
‎2009 May 24 9:05 AM
Hi Radhika,
>
> if i_final-augbl eq space .
>
replace by
if i_final-augbl eq ''.
don't put space between the single quotes.
Best regards,
Shahid Malayil
‎2009 May 24 9:45 AM
‎2009 May 24 9:51 AM
Hi,
Check for INITIAL
loop at i_final.
if i_final-augbl IS INITIAL .
loop at i_final1.
‎2009 May 24 10:03 AM
Hi try this code,
loop at i_final1.
loop at i_final where augbl eq space .
i_final1-mblnr = i_final-mblnr.
i_final1-mjahr = i_final-mjahr.
i_final1-budat = i_final-budat.
i_final1-xblnr = i_final-xblnr.
i_final1-bldat = i_final-bldat.
i_final1-frbnr = i_final-frbnr.
i_final1-bktxt = i_final-bktxt.
i_final1-lifnr = i_final-lifnr.
i_final1-name = i_final-name.
i_final1-matnr = i_final-matnr.
i_final1-maktx = i_final-maktx.
i_final1-ebeln = i_final-ebeln.
i_final1-aedat = i_final-aedat.
i_final1-belnr = i_final-gjahr.
endloop.
endloop.
thanks
anil dasari
‎2009 May 24 9:14 AM
Hi,
Try making use of if i_final-augbl is initial.
Also i find your append statement missing in the loop.
Regards,
Ankur Parab
‎2009 May 24 10:51 AM
Hi,
Use the below code. Note that i added append statement which was missing in your original code. Thanks.
clear i_final1.
refresh i_final1.
if i_final[] is not initial.
loop at i_final.
if i_final-augbl eq space .
loop at i_final1.
i_final1-mblnr = i_final-mblnr.
i_final1-mjahr = i_final-mjahr.
i_final1-budat = i_final-budat.
i_final1-xblnr = i_final-xblnr.
i_final1-bldat = i_final-bldat.
i_final1-frbnr = i_final-frbnr.
i_final1-bktxt = i_final-bktxt.
i_final1-lifnr = i_final-lifnr.
i_final1-name = i_final-name.
i_final1-matnr = i_final-matnr.
i_final1-maktx = i_final-maktx.
i_final1-ebeln = i_final-ebeln.
i_final1-aedat = i_final-aedat.
i_final1-belnr = i_final-gjahr.
append i_final1 to i_final.
endloop.
endif.
endloop.
endif.
‎2009 May 24 11:30 AM
Try below:
if i_final-augbl is initial or i_final-augbl is null.
loop at i_final1.
..
..
append i_final1.
endloop.
endif.
‎2009 May 24 11:32 AM
‎2009 May 24 12:44 PM
As Ankur Parab first pointed out, you've populated the ifinal1 header, but not appended it to the table.
Using tables with header lines is not good programming. It leads to confusion, because it is not immediately obvious when you refer to "ifinal1" whether you mean the table, or its header.
Far better to declare a separate work area. ( Which, incidentally, you are forced to do in an objects context ).
I also note, that you've got your internal tables confused. The first thing you do is refresh i_final1, then you want to LOOP through it?! It makes no sense.
DATA: ls_final1 LIKE LINE OF i_final1,
ls_final LIKE LINE OF i_final.
...
loop at i_final INTO ls_final.
---
loop at i_final1 INTO ls_final1.
ls_final1-mblnr = ls_final-mblnr.
...
APPEND ls_final1 TO i_final1.
endloop.
...
endloop.
...
Edited by: Matt on May 24, 2009 1:45 PM
‎2009 May 24 12:50 PM
Hi,
I think couple thinks should be clarified here:
1) Are i_final and i_final1 of the same structure? If so, there should be not explicit addressing of components used, instead you should use move-corresponding or even better use i_final[ ] = i_fnal1[ ]
2) as explained by all posters above to check if i_final-augbl holds some value use either if it is initial or eq space (if this is character type field)
3) you are clearing i_final1 (content + header) at the beginning, so why do you loop at i_final1 later. It's empty there, that's why you can't append any entry to it. Processing simply never goes inside that, so no fields are moved to i_final1.
Considering above this is how the code should look like:
"emty your destination table
clear i_final1.
refresh i_final1.
"now move content from source table to your destination table
if i_final[] is not initial.
loop at i_final. "loop at source table
if i_final-augbl is initial. "or eq space if character type
move-corresponding i_final to i_final1. "if structures differ a bit, but most components are same
append i_final1.
endif.
endloop.
endif.
"another solution
"if structures are excatly the same and AUGBL is a key field
if i_final[] is not initial.
i_final[] = i_final1[]. "copy entire content
endif.
"now delete those record which stay empty at field AUGBL
delete table i_final1 with key AUGBL = space. "augbl must be a key field
Regards
Marcin