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: 

IT0008 - LGAXX - Field Symbols & case stmt

Former Member
0 Kudos
1,355

Hi all...

In IT0008, we have lga01-lga40.

Using a field symbol i have to modify the components lgaxx.

I know the index or LGAxx component which i hav to modify.

I hav modified the component LGAxx using a case stmt.

But it becomes too lengthy as there are 40 LGAxx components..

Can anyone simplify it?

-


Ex:

assign innnn to <p0008> casting.

Loop at p0008.

do 40 times varying xxxxxxx.

get the index where i have to modify, say v_index.

enddo.

endloop.

case v_index.

when 1.

<p0008>-lga01 = 'value'.

when 2.

<p0008>-lga02 = 'value'.

etc..etc..

when 40.

<p0008>-lga40 = 'value'.

endcase.

-


How can I modify the above case stmt to make it simple.

Or, how can I loop through a field symbol and modify the field symbol comonent

at a particular index.

ex:

loop at <p0008>.

if sy-index = 5.

<p0008>-lga05 = 'value'.

endloop.

Either of the answers can help me simplify my code a lot.

Regards,

Veeranji Reddy P.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
354

Hi Veeranji,

This code snippet modifies the value of betXX in the structure wa_0008, if LGAXX value is 'MC20'.


TYPES: BEGIN OF ty_wages,
          lgart TYPE p0008-lga01,
          betrg TYPE p0008-bet01,
       END OF ty_wages.


DATA wa_0008 TYPE pa0008.
FIELD-SYMBOLS  <fs_wages> TYPE ty_wages.
data wa_wages type ty_wages.

SELECT SINGLE * FROM pa0008 INTO wa_0008 WHERE pernr = '1331'.

ASSIGN wa_wages to  <fs_wages>.
DO 40 TIMES VARYING <fs_wages>-lgart FROM wa_0008-lga01 NEXT wa_0008-lga02
            VARYING <fs_wages>-betrg FROM wa_0008-bet01 NEXT wa_0008-bet02.

if <fs_wages>-lgart = 'MC20'.
  <fs_wages>-betrg = '500'.
  endif.
ENDDO.

11 REPLIES 11

Former Member
0 Kudos
354

Hi,

you need to create one more internal table which contains the component values. with the LGAXX.

then loop your main internal table and then read with the second internal table with the partiulare index and the LGAXX. then assign that value to the main loop work area with the modifying the same table.

it will solve your problem.

Ex: loop <P_LGAV> assinging <ps_lgav>.

read table it_value into wa_value with index.

if sy-subrc = 0.

ps_lgav-value = wa_value-value.

modify p_lgav from the <ps_lgav> with index tranporting value.

endif.

endloop.

Former Member
0 Kudos
355

Hi Veeranji,

This code snippet modifies the value of betXX in the structure wa_0008, if LGAXX value is 'MC20'.


TYPES: BEGIN OF ty_wages,
          lgart TYPE p0008-lga01,
          betrg TYPE p0008-bet01,
       END OF ty_wages.


DATA wa_0008 TYPE pa0008.
FIELD-SYMBOLS  <fs_wages> TYPE ty_wages.
data wa_wages type ty_wages.

SELECT SINGLE * FROM pa0008 INTO wa_0008 WHERE pernr = '1331'.

ASSIGN wa_wages to  <fs_wages>.
DO 40 TIMES VARYING <fs_wages>-lgart FROM wa_0008-lga01 NEXT wa_0008-lga02
            VARYING <fs_wages>-betrg FROM wa_0008-bet01 NEXT wa_0008-bet02.

if <fs_wages>-lgart = 'MC20'.
  <fs_wages>-betrg = '500'.
  endif.
ENDDO.

0 Kudos
354

Hi Prasanth....

-


Ex: loop <P_LGAV> assinging <ps_lgav>.

read table it_value into wa_value with index.

if sy-subrc = 0.

ps_lgav-value = wa_value-value.

modify p_lgav from the <ps_lgav> with index tranporting value.

endif.

endloop.

-


In ur code, ps_lgav-value : ps_lgav is ok..

but "value", lga01 or lga02 or ...how can I get this one?

I know the index, it is 5 say..then I hav to modify LGA05.

How can I dynamically modify <p0008>-lga05 = 'VALUE' ?

0 Kudos
354

Hi try this code for ur requirement:


INFOTYPES: 0008.
DATA: G_LGART TYPE PA0008-LGA01,
       G_BETRG TYPE PA0008-BET01. 
 
DO 40 TIMES VARYING g_lgart FROM P0008-LGA01 NEXT P0008-LGA02
            VARYING G_BETRG FROM P0008-BET01 NEXT P0008-BET02.
  IF SY-INDEX = 5.
    G_LGART = 'VALUE'.
  ENDIF.    
ENDDO.  

It will dynamically modify <p0008>-lga05 ans assign it value 'VALUE'

0 Kudos
354

Hi Amit..

I guess ur idea works...

But...how can I loop through field symbol?

Before the DO stmt I hav to loop through field symbol...<p0008>..

loop at <p0008> into xxx...plz explain this stmt...

Regards,

Veeranji Reddy P.

0 Kudos
354

Hi veer,

If you want to do loop on a field symbol table then you need to take the following care.

While declaring the Field symbols.

field-symbols: <FS> type table of p0008,
                     <FS1> type p0008.

In the above case you can loop as below.

loop at <FS> into <FS1>.

<FS1>-PERNR =  .........
....................................

ENDLOOP.

in case you declare the field symbol as below.

FIELD-SYMBOLS: <TAB> TYPE TABLE,
               <DYN_WA>.

FIELD-SYMBOLS: <TAB_TMP> TYPE TABLE,
               <DYN_WA_TMP>.


 LOOP AT <TAB> ASSIGNING <DYN_WA>.

        ASSIGN COMPONENT 'MARK'  OF STRUCTURE <DYN_WA> TO <FS2>.

        IF <FS2> EQ 'X'.

          MOVE-CORRESPONDING <DYN_WA> TO <DYN_WA_TMP>.
          DELETE TABLE <tab> from <dyn_wa>.

          APPEND <DYN_WA_TMP> TO <TAB_TMP>.

          CLEAR <DYN_WA_TMP>.

        ENDIF.

      ENDLOOP.

I only hope I got your requirement correct.

Murthy.

Edited by: pr murthy on Dec 29, 2008 9:44 AM

0 Kudos
354

Hi Murthy...

In ur code the component 'mark' is not a single one.. it changes from lga01 to lga40....

How can i represent all the 40 lgaxxs? [in ur code MARK can be anyone of lgaxx]

-


Let me explain in detail.

In one exit, i hav innnn as import parameter.

Assign innnn to <p0008> casting.

My table <p0008> and in every record of this table , (<p0008> is a field symbol of type p0008)

I have pernr, infty, subty, xxx, lga01, lga02,..lga40.

Now,

loop through <p0008>.

do 40 times varying lgart from lga01 next lga02.

if lgart is initial.

STEP 1: Here I have to update the <p0008>-lgart (<p0008>-lga'sy-index' = <p0008>-lga06

if sy-index is 6).

[update in the sence to put a value in tha component of <p0008>]

endif.

enddo.

endloop.

What I am doing at present is...

at STEP 1: storing the index.

and

case index.

when 1.

<p0008>-lga01 = 'value'.

when 2.

<p0008>-lga02 = 'value'.

.....................

when 40.

<p0008>-lga40 = 'value'.

endcase.

Here the case looks so big and bad as it has 40 when stmts.

And I have to use the same case twice.

Please simplify it into one loop without any case stmt.

Edited by: Veeranji Reddy on Dec 29, 2008 2:44 PM

0 Kudos
354

Hello Reddy,

Are you using logical database to get values from HR tables ? If yes than I believe you do not need to do anything but as said by Amit Gupta, because you would be having the latest value in header line of P0008 internal table.

Regards,

Jayant Sahu.

0 Kudos
354

Hi Sahu.

Actually I am writing all my code in a EXIT. PBAS0001-exit0001.

Here innnn is an import paramater.

I am assiging this innnn to <p0008> field symbol.

And the remaining is explained in my above post.

( I have to loop through <p0008>...and have to use do varying for sure... )

Regards,

Veeranji Reddy P.

Edited by: Veeranji Reddy on Dec 29, 2008 3:05 PM

Former Member
0 Kudos
354

This is special statement in HR ABAP. No need to use case statement, use this:


INFOTYPES: 0008.
DATA: G_LGART TYPE PA0008-LGA01,
      G_BETRG TYPE PA0008-BET01.


DO 40 TIMES VARYING g_lgart FROM P0008-LGA01 NEXT P0008-LGA02
            VARYING G_BETRG FROM P0008-BET01 NEXT P0008-BET02.
  
  " NOW G_LGART HOLDS THE MEMORY OF P0008-LGAR01 IN 1ST LOOP, P0008-LGA02 IN 
  " SECOND LOOP ANS SO ON....AND SAME IS APPLICABLE TO G_BETRG
  " i.e. G_LGART AND G_BETRG ACTS AS FIELD SYNMBOLS
  " NOW WE CAN USE 2 OPERATIONS
  "1) RETREIVE DATA FROM P0008-LGAXX
  " SIMPLY DO THE REQURED PROCESSING ON G_LGART
  " e.g
  IF G_LGART = '1BAS'.
  G_SALARY = G_SALARY + G_LGART.
  ENDIF.  
  "2) PUT DATA INTO P0008-LGAXX
  " SIMPLY PUT DATA INTO G_LGART AND IT WILL BE ASSIGNED TO P0008-LGAXX 
  " WHERE XX DEPENDS ON LOOP NUMBER OF DO..ENDDO LOOP
  " e.g 
  IF G_LGART = 1BAS.
    G_BETRG = 5000.
  ENDIF. 
   
ENDDO.  

Former Member
0 Kudos
354

All the replies gave some clues, and did my using them.