2009 Aug 04 1:45 PM
I picked up date from a table say itab which is being uploaded from a text file in DD.MM.YYYY. Then I changed it to YYYYMMDD and passed it to a variable in another table which i am using further but if this date is blank in text file then also value of this variable is not initial.
LOOP AT itab[] INTO itab.
CONCATENATE itab-bldat+6(4) itab-bldat+3(2) itab-bldat+0(2) INTO itab-bldat.
CONDENSE itab-bldat.
CLEAR: v_bldat , v_budat.
v_bldat = itab-bldat.
gs_main_load-bldat = v_bldat...........
IF gs_main_load-bldat IS NOT INITIAL AND " document date
......................................
APPEND gs_main_load TO git_input1. <<<<<<<<<<<<<<<<<< **Program goes here instead going after "else".
Else.
.................
endif.
Please help me.
Edited by: Matt on Aug 4, 2009 4:28 PM
2009 Aug 04 1:48 PM
Hi,
Check the change in the code.The one in BOLD.
LOOP AT itab[] INTO itab.
CONCATENATE itab-bldat6(4) itab-bldat3(2) itab-bldat+0(2) INTO itab-bldat.
CONDENSE itab-bldat.
CLEAR: v_bldat , v_budat.
v_bldat = itab-bldat.
gs_main_load-bldat = v_bldat...........
IF gs_main_load-bldat NE '00000000' AND " document date......................................
APPEND gs_main_load TO git_input1.
Else.
.................
endif.
Regards,
Vimal.
2009 Aug 04 1:48 PM
Hi,
Check the change in the code.The one in BOLD.
LOOP AT itab[] INTO itab.
CONCATENATE itab-bldat6(4) itab-bldat3(2) itab-bldat+0(2) INTO itab-bldat.
CONDENSE itab-bldat.
CLEAR: v_bldat , v_budat.
v_bldat = itab-bldat.
gs_main_load-bldat = v_bldat...........
IF gs_main_load-bldat NE '00000000' AND " document date......................................
APPEND gs_main_load TO git_input1.
Else.
.................
endif.
Regards,
Vimal.
2009 Aug 04 1:58 PM
2009 Aug 04 2:06 PM
Hello Sonu,
I think
IF gs_main_load-bldat IS NOT INITIAL
is correct.
You need to clear the work area:
CLEAR gs_main_load.
BR,
Suhas
2009 Aug 04 2:19 PM
Hello Guys,
Did you see the code corectly? The OP has not cleared the workarea.
LOOP AT itab[] INTO itab.
CONCATENATE itab-bldat+6(4) itab-bldat+3(2) itab-bldat+0(2) INTO itab-bldat.
CONDENSE itab-bldat.
CLEAR: v_bldat , v_budat.
v_bldat = itab-bldat.
gs_main_load-bldat = v_bldat........... "gs_main_load-bldat is populated here
IF gs_main_load-bldat IS NOT INITIAL AND " document date
......................................
APPEND gs_main_load TO git_input1. <<<<<<<<<<<<<<<<<< **Program goes here instead going after "else".
CLEAR gs_main_load. "--> Add this line
Else.
.................
ENDIF.
I am damn sure the issue has got nothing to do with INITIAL.
BR,
Suhas
2009 Aug 04 2:25 PM
Yes thats true. only if the first record of the internal table itab[] is initial, it will go to the else part. The problems lies in clearing the work area.
APPEND gs_main_load TO git_input1. <<<<<<<<<<<<<<<<<< **Program goes here instead going after "else".
CLEAR gs_main_load.
2009 Aug 04 3:33 PM
>CLEAR: v_bldat , v_budat.
>v_bldat = itab-bldat.
>gs_main_load-bldat = v_bldat........... "gs_main_load-bldat is populated here
>IF gs_main_load-bldat IS NOT INITIAL AND " document date
Look at v_bldat. It's cleared in the loop. Then it is assigned the value from ITAB. Then that is passed to gs_main_load-bldat. Then gs_main_load-bldat is getting the value of v_bldat.
SO... it isn't the workarea not being cleared, because the field being testing "is" being cleared.
To the original poster. Set a breakpoint at the IF, and find the value of gs_main_load-bldat when itab-bldat "is blank".
matt
2009 Aug 04 1:50 PM
Hello,
After the APPEND stmt you have to CLEAR the work area.
APPEND gs_main_load TO git_input1.
CLEAR gs_main_load . "-->Add this line
BR,
Suhas
2009 Aug 04 2:15 PM
Hi,
data : l_data(8) type c,
write gs_main_load-bldat to l_data.
SHIFT l_data LEFT DELETING LEADING '0'.
IF l_data is not INITIAL AND " document date
......................................
APPEND gs_main_load TO git_input1. <<<<<<<<<<<<<<<<<< **Program goes here instead going after "else".
Else.
.................
endif.
2009 Aug 04 3:58 PM
Hi,
You are just assigning the value into gs_main_load-bldat and immediately chekcing so the value is there so
that condition is becoming true. Keep break point at if condition then check the value is existing or not.
gs_main_load-bldat = v_bldat...........
IF gs_main_load-bldat IS NOT INITIAL AND " document date
......................................
APPEND gs_main_load TO git_input1. <<<<<<<<<<<<<<<<<< **Program goes here instead going after "else".
Else.
.................
endif.
Regards,
Ganesh