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

script - subroutine pool.

Former Member
0 Likes
825

Hi Experts,

In my main window i want the list of line items to b displayed. by keeping a loop. am able to select the items but unable to keep the loop .am pasting my code here plz correct me.

am able to select the line items but my loop z wrong and plz help me with the se71 part...

correct answers will be given full points....

DATA : zbelnr LIKE bkpf-belnr.

  DATA:     zam LIKE bsak-wrbtr.

  TYPES : BEGIN OF t_bsak,
          zid LIKE bsak-bldat,
          zin LIKE bsak-belnr,
          zpo LIKE bsak-ebeln,
          zde LIKE bsak-sgtxt,
          zam1 LIKE bsak-wrbtr,
          END OF t_bsak.
  DATA : wa_bsak TYPE t_bsak,
         it_bsak TYPE STANDARD TABLE OF t_bsak.

  READ TABLE in_par WITH KEY 'BKPF-BELNR'.
  CHECK sy-subrc = 0.
  zbelnr = in_par-value.


  SELECT bldat belnr ebeln sgtxt wrbtr INTO  TABLE
  it_bsak FROM bsak WHERE augbl EQ zbelnr
  AND buzei = '1'.

  LOOP AT it_bsak INTO wa_bsak.

    zam = wa_bsak-zam1.
    LOOP AT out_par.
      CASE out_par-name.
        WHEN 'ZID'.
          out_par-value = wa_bsak-zid.
          MODIFY out_par.
      ENDCASE.
      CASE out_par-name.
        WHEN 'ZIN'.
          out_par-value = wa_bsak-zin.
          MODIFY out_par.
      ENDCASE.
      CASE out_par-name.
        WHEN 'ZPO'.
          out_par-value = wa_bsak-zpo.
          MODIFY out_par.
      ENDCASE.
      CASE out_par-name.
        WHEN 'ZDE'.
          out_par-value = wa_bsak-zde.
          MODIFY out_par.
      ENDCASE.
      CASE out_par-name.
        WHEN 'ZAM'.
          out_par-value = zam.
          MODIFY out_par.
      ENDCASE.
    ENDLOOP.
  ENDLOOP.

Regards

Sunita.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
719

Hi Sunita,

Goto saptechnical.com there under Tutorials search with "PassingTableData" u will get my blog on this topic. May be it will help u.

Regards,

Joy.

5 REPLIES 5
Read only

Former Member
0 Likes
719

hi experts,

please help me

regards

sunita.

Read only

Former Member
0 Likes
719

Hi Sunitha,

I think your code is fine. and to get data from a loop you have to write a subroutine pool in se38.like this code you write in se38 and name some 'ZXXX'.

1.In se71 you go to the place where you are fetching this data write like this:

PERFORM GET_DATA IN PROGRAM ZFREIGHT3

USING &VBDKA-KNUMV&

CHANGING &FREIGHT&

ENDPERFORM.

ZFREIGHT3----> name of the subroutine

&VBDKA-KNUMV&-------> name of the parameter you are checking as in your case statement.

&FREIGHT&----


> value of the field which you want to pass in the script.

2. Then you go to se38 and create a subroutine and write like this

FORM get_data TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy.

READ TABLE in_tab INDEX 1.

IF sy-subrc = 0 .

knum = in_tab-value.

ENDIF.

-


your code to fetch data

-


READ TABLE out_tab WITH KEY name = 'FREIGHT'.

IF sy-subrc = 0 .

IF amt IS NOT INITIAL .

out_tab-value = amt .

MODIFY out_tab INDEX sy-tabix.

endif.

endif.

ENDFORM. "get_data

-


you set your paraetrs according to your code and fields.Imp thing is that you keep in mind the read table for in_tab and out_tab as these value will be returnrd to your code.

hope you can do now .if still finds any prob then let us know.

gudluck.Rewards if useful.

Regards

Binod

Read only

Former Member
0 Likes
719

Hi Sunitha,

i think the req what ur asking is like , you want to get multiple line items by passing the ZBELNR from script and display all the line items. This is not possible in scripts.. Looping of line items can be handled only from Driver program.So better change the driver program.

Regards

Raj.D

Read only

Former Member
0 Likes
719

Hi Sunita,

Use the Subrouting and call that subroutine from and element.. This will resolve your problem.

Read only

Former Member
0 Likes
720

Hi Sunita,

Goto saptechnical.com there under Tutorials search with "PassingTableData" u will get my blog on this topic. May be it will help u.

Regards,

Joy.