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

Regarding If condition

Former Member
0 Likes
1,222
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

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
1,186

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

10 REPLIES 10
Read only

shahid_malayil1
Explorer
0 Likes
1,186

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

Read only

0 Likes
1,186

i have already tried it but it was not working!!!

Read only

0 Likes
1,186

Hi,

Check for INITIAL

loop at i_final.
if i_final-augbl IS INITIAL .
loop at i_final1.

Read only

0 Likes
1,186

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

Read only

Former Member
0 Likes
1,186

Hi,

Try making use of if i_final-augbl is initial.

Also i find your append statement missing in the loop.

Regards,

Ankur Parab

Read only

Former Member
0 Likes
1,186

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.

Read only

Former Member
0 Likes
1,186

Try below:

if i_final-augbl is initial or i_final-augbl is null.

loop at i_final1.

..

..

append i_final1.

endloop.

endif.

Read only

0 Likes
1,186

Sorry, typo

append i_final1.

should be

append i_final.

Read only

matt
Active Contributor
0 Likes
1,186

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

Read only

MarcinPciak
Active Contributor
0 Likes
1,187

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