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

tax code description from t007s

Former Member
0 Likes
3,066

Hi Expert..


I have problem to display the tax description as below



program code as below:


clear lt_t007s.

          SELECT  mwskz text1 kalsm

          INTO TABLE lt_t007s

          FROM t007s

            FOR ALL ENTRIES IN lt_ekpo

          WHERE mwskz = lt_ekpo-mwskz AND kalsm = 'TAXMY'.

   IF sy-subrc EQ 0.

   sort lt_t007s by mwskz.

   ENDIF.

   LOOP AT lt_t007s INTO lw_t007s.

      READ TABLE lt_t007s INTO lw_t007s with key mwskz = lw_ekpo-mwskz Binary search.

        IF sy-subrc eq 0.

           it_output-t007s-text1 = lw_t007s-text1.

           it_output-t007s-mwskz = lw_t007s-mwskz.

           it_output-t007s-kalsm = lw_t007s-kalsm.

        ENDIF.

    ENDLOOP.



when i debug, the value are correctly filled as below:



Thus, what else i can do so that the output can be displayed.

please help and guide me.


ur kindness most appreciated


Thanks, regards.

liyana


1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,419

hii liyana.

you are reading same table in loop and in condition you are comparing it with ekpo table.

please change your loop also add modify table statement in your logic.

Regards

Gaurav

Hi Expert..


I have problem to display the tax description as below



program code as below:


clear lt_t007s.

          SELECT  mwskz text1 kalsm

          INTO TABLE lt_t007s

          FROM t007s

            FOR ALL ENTRIES IN lt_ekpo

          WHERE mwskz = lt_ekpo-mwskz AND kalsm = 'TAXMY'.

   IF sy-subrc EQ 0.

   sort lt_t007s by mwskz.

   ENDIF.

   LOOP AT lt_t007s INTO lw_t007s.

      READ TABLE lt_t007s INTO lw_t007s with key mwskz = lw_ekpo-mwskz Binary search.

        IF sy-subrc eq 0.

           it_output-t007s-text1 = lw_t007s-text1.

           it_output-t007s-mwskz = lw_t007s-mwskz.

           it_output-t007s-kalsm = lw_t007s-kalsm.

        ENDIF.

    ENDLOOP.



when i debug, the value are correctly filled as below:



Thus, what else i can do so that the output can be displayed.

please help and guide me.


ur kindness most appreciated


Thanks, regards.

liyana


9 REPLIES 9
Read only

Former Member
0 Likes
2,420

hii liyana.

you are reading same table in loop and in condition you are comparing it with ekpo table.

please change your loop also add modify table statement in your logic.

Regards

Gaurav

Read only

archanapawar
Contributor
0 Likes
2,419

Hi Liyana,

Cahnge your loop to below code. It will work.

LOOP AT lt_ekpo INTO lw_ekpo.

      READ TABLE lt_t007s INTO lw_t007s with key mwskz = lw_ekpo-mwskz Binary search.

        IF sy-subrc eq 0.

           it_output-t007s-text1 = lw_t007s-text1.

           it_output-t007s-mwskz = lw_t007s-mwskz.

           it_output-t007s-kalsm = lw_t007s-kalsm.

        ENDIF.

    ENDLOOP.

Read only

PeterJonker
Active Contributor
0 Likes
2,419

You made a mistake in:

READ TABLE lt_t007s INTO lw_t007s with key mwskz = lw_ekpo-mwskz (this one is Always empty)

If you do this you need to loop at lt_ekpo into lw_ekpo, but you are looping around the table lt_t007s and then read the same table with a work area that will therefore always be empty.

Hence sy-subrc will Always be <> 0 and your output will not be filled.

It should be constructed somehow like:

1. Select all the entries from EKPO and place them in LT_EKPO

2. Select all entries from t007s (for all entries after checking lt_ekpo is not initial)and place them in table lt_t007s

3. Loop around LT_EKPO and READ LT_T007s

4. move the fields from LW_ekpo and LW_T007S to the respective output fields.

I also see in the screen shot that you created a deep structure as output. Not a good idea.

Why don't you define an output type that only holds the fields you ant to show w/o any deep structure e.g:

Types: Begin of type ty_output,

              mwskz type mwskz,

              kalsm type kalsm_d,

              text1 type text1_007s

           end of ty_output,

           tt_output type standard table of ty_output.

Data: lt_output type tt_output,

          lwa_output type ty_output.

Offcourse you need to add all fields to the output table that you want to show.

Next to that I would not use TAXMY hardcoded but also read this from the corresponding table ( I think it is the EKKO table)

Read only

Former Member
0 Likes
2,419

after change the loop, it still cannot display the tax code.

regards,

liyana

Read only

0 Likes
2,419

Well then there must be another mistake in the code which we cannot see. Can you place the full code or attach it ?

Read only

0 Likes
2,419

Hi Liyana,

I am not sure how you have defined you it_output table. Declare a work area for that and append the work area to internal table it_output.

Types: Begin of type ty_output,

              mwskz type mwskz,

              kalsm type kalsm_d,

              text1 type text1_007s

           end of ty_output.

Data: lt_output type standard table of ty_output,

          lwa_output type ty_output.

LOOP AT lt_ekpo INTO lw_ekpo.

      READ TABLE lt_t007s INTO lw_t007s with key mwskz = lw_ekpo-mwskz Binary search.

        IF sy-subrc eq 0.

           lw_output-t007s-text1 = lw_t007s-text1.

           lw_output-t007s-mwskz = lw_t007s-mwskz.

           lw_output-t007s-kalsm = lw_t007s-kalsm.

          

          append lw_output to it_output.

        ENDIF.

    ENDLOOP.

Read only

Former Member
0 Likes
2,419

pls provide your select query and data defination

Read only

VenkatRamesh_V
Active Contributor
0 Likes
2,419

Hi,

Check your append statement .

Regards,

Venkat.

Read only

Former Member
0 Likes
2,419

thanks everyone, the problem already solved. i put below select statement inside looping of lw_ekpo, then, append to it_output.

CLEAR lt_t007s.

        SELECT mwskz text1 kalsm

         INTO CORRESPONDING FIELDS OF TABLE lt_t007s

         FROM t007s

         WHERE mwskz = lw_ekpo-mwskz AND kalsm = 'TAXMY'.

      IF sy-subrc EQ 0.

      sort lt_t007s by mwskz.

      ENDIF.

      READ TABLE lt_t007s INTO lw_t007s with key mwskz = lw_ekpo-mwskz Binary search.

        IF sy-subrc eq 0.

           it_output-t007s-text1 = lw_t007s-text1.

           it_output-t007s-mwskz = lw_t007s-mwskz.

           it_output-t007s-kalsm = lw_t007s-kalsm.

        ENDIF.

Thanks, regards

liyana