Skip to Content
avatar image
Former Member

Displaying line items in SAP script layout using subroutine pool

Hi All,

I am working on SAP script in which there is a requirement wherein, I have to fetch values from tables for line items in the Main Window. As per my coding, right now it will fetch only the first value from the table. It is fine if there is only one line item. But if there are more than one line items I need to fetch all the values and display them.

Could anyone suggest any way this can be done.

Thanks

Neha

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jan 07, 2009 at 05:07 AM

    IN sapscript

    /: PERFORM GET_BILL_PARTNER IN PROGRAM XYZ

    /: USING &VBDKL-VBELN&

    /: CHANGING &BILL_TO_PART&

    /: ENDPERFORM

    IN Subroutine program >> XYZ(in SE38)

    FORM get_bill_partner TABLES input_table STRUCTURE itcsy

    output_table STRUCTURE itcsy.

    DATA: lws_vbeln LIKE vbak-vbeln, "Sales Number

    lws_kunnr LIKE vbpa-kunnr,

    lws_parvw LIKE vbpa-parvw.

    • Read the input variables.

    LOOP AT input_table.

    lws_vbeln = input_table-value.

    ENDLOOP.

    *Add leading zero's to delivery number

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    input = lws_vbeln

    IMPORTING

    output = lws_vbeln.

    CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'

    EXPORTING

    input = 'BP'

    IMPORTING

    output = lws_parvw.

    SELECT SINGLE kunnr INTO lws_kunnr

    FROM vbpa

    WHERE vbeln = lws_vbeln

    AND parvw = lws_parvw.

    *Pass Ship-To Party value

    LOOP AT output_table.

    IF output_table-name = 'BILL_TO_PART'. "Description of Shipment

    output_table-value = lws_kunnr.

    ENDIF.

    MODIFY output_table.

    ENDLOOP.

    I guess this will resolve your question

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 07, 2009 at 04:26 PM

    The correct solution would be to modify the print program to loop through the table and call a text element to print the line.

    If you can't modify the print program you could use a series of PERFORMs in the SAPScript, each retrieving a different specific line. This is a bad solution, since you need to create as many PERFORMs as the maximum possible lines in the table for the item.

    Add comment
    10|10000 characters needed characters exceeded