Application Development 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: 

regarding work area is not being initialized

Former Member
0 Kudos
173

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos
121

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.

9 REPLIES 9

Former Member
0 Kudos
122

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.

0 Kudos
121

instead of using NE '00000000" I should use NE ' '.

0 Kudos
121

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

0 Kudos
121

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

0 Kudos
121

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. 

matt
Active Contributor
0 Kudos
121

>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

SuhaSaha
Advisor
Advisor
0 Kudos
121

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

Former Member
0 Kudos
121

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.

Former Member
0 Kudos
121

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