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

Internal table

Former Member
0 Likes
490

Hi Friends,

I have an internal table with the columns : Material, Apr, May, Jun, Jul, Aug ..... Mar.

Based on some condition, i am updating this table.

I have also an input field which accepts the month. If my input month is Sep'06, then the data in the internal table for the columns Apr to Aug should become 0.

Could any guide me how to do this in a simple way.

TIA.

Regards,

Mark K

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
459

Hi Mark

You can use the below for the startup and improvise

basing on your requirement.

FIELD-SYMBOLS: <WA_TAB>, <TEMP>.
DATA: L_KEY TYPE I,
      L_NUM TYPE I.

CASE P_INPUT.
WHEN 'APR'.
   L_KEY = 2.
WHEN 'MAY'.
   L_KEY = 3.
WHEN 'JUN'.
   L_KEY = 4.
WHEN 'JUL'.
   L_KEY = 5.
WHEN 'AUG'.
   L_KEY = 6.
WHEN 'SEP'.
   L_KEY = 7.
WHEN 'OCT'.
   L_KEY = 8.
WHEN 'NOV'.
   L_KEY = 9.
WHEN 'DEC'.
   L_KEY = 10.
WHEN 'JAN'.
   L_KEY = 11.
WHEN 'FEB'.
   L_KEY = 12.
WHEN 'MAR'.
   L_KEY = 13.
ENDCASE.

LOOP AT IT_TAB ASSIGNING <WA_TAB>.
  L_NUM = 2.
  DO.
   ASSIGN COMPONENT L_NUM OF STRUCTURE <WA_TAB> TO <TEMP>.
   IF SY-SUBRC EQ 0.
      IF L_NUM < L_KEY.
         CLEAR: <TEMP>.
      ENDIF.
   L_NUM = L_NUM + 1.
   ELSE.
   EXIT.
   ENDIF.
 ENDDO.
ENDLOOP.

Kindly note that L_KEY and L_NUM denotes the column

positions to identify.

Kind Regards

Eswar

Message was edited by: Eswar Rao Boddeti

4 REPLIES 4
Read only

Former Member
0 Likes
460

Hi Mark

You can use the below for the startup and improvise

basing on your requirement.

FIELD-SYMBOLS: <WA_TAB>, <TEMP>.
DATA: L_KEY TYPE I,
      L_NUM TYPE I.

CASE P_INPUT.
WHEN 'APR'.
   L_KEY = 2.
WHEN 'MAY'.
   L_KEY = 3.
WHEN 'JUN'.
   L_KEY = 4.
WHEN 'JUL'.
   L_KEY = 5.
WHEN 'AUG'.
   L_KEY = 6.
WHEN 'SEP'.
   L_KEY = 7.
WHEN 'OCT'.
   L_KEY = 8.
WHEN 'NOV'.
   L_KEY = 9.
WHEN 'DEC'.
   L_KEY = 10.
WHEN 'JAN'.
   L_KEY = 11.
WHEN 'FEB'.
   L_KEY = 12.
WHEN 'MAR'.
   L_KEY = 13.
ENDCASE.

LOOP AT IT_TAB ASSIGNING <WA_TAB>.
  L_NUM = 2.
  DO.
   ASSIGN COMPONENT L_NUM OF STRUCTURE <WA_TAB> TO <TEMP>.
   IF SY-SUBRC EQ 0.
      IF L_NUM < L_KEY.
         CLEAR: <TEMP>.
      ENDIF.
   L_NUM = L_NUM + 1.
   ELSE.
   EXIT.
   ENDIF.
 ENDDO.
ENDLOOP.

Kindly note that L_KEY and L_NUM denotes the column

positions to identify.

Kind Regards

Eswar

Message was edited by: Eswar Rao Boddeti

Read only

0 Likes
459

Thanks a lot.

Regards,

Mark K

Read only

Former Member
0 Likes
459

Hi,

wa-may = 0.

...

wa-aug = 0.

MODIFY ITab FROM Wa TRANSPORTING apr may jun jul aug.

Regards,

bala

Message was edited by: krithika balamurughan

Read only

Former Member
0 Likes
459

The logic can be as follows...

pmonth <= your input field.

lmon = pmonth(3). "ie. SEP

Select mnr into lper from t247

where spras = sy-langu and ktx = lmon.

if lper <> 0.

loop at itab.

lper = lper + 1.

do lper times.

assign component of structure itab to <f>.

if sy-subrc = 0.

check sy-index <> 1.

<f> = 0.

modify itab.

else.

exit.

endif.

enddo.

endloop.