Skip to Content
author's profile photo Former Member
Former Member

Subroutines in Layouts

Hi All,

I am trying to use the form-perform statements in layouts, but it is displaying only one record, the last record. I want to diaply all the records satisfying that condition. In debug mode, i can see all the records, but it overwrited every time, so just the last rec is returned in the print layout.

Eg, i am trying to incluse PO history data in PO print.

I created form perfom. Now for each PO there are 5-6 records of History.. i want to display all in the PO. Right nowits displaying just the last one.

Also, from EKBE, i need to take 6 fields. Do i need to define a form perform individually for all fields. That means a set of 6 performs in layout and 6 forms in program.

Please help.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2005 at 12:29 PM

    Use the transfer routines as in the example below:

    REPORT zz_sapscript_forms .

    ********************DO NOT DELETE THIS PROGRAM EVER*****************

    • This is a pool of subroutines used in Centrex Goods Issue (MB90) and

    • Service Order (IW32) SAPScript Forms.

    ----


    • FORM GET_SERVICE_CENTRE_ADDR *

    ----


    • ........ *

    ----


    • --> INPUT *

    • --> OUTPUT *

    ----


    FORM get_service_centre_addr TABLES input STRUCTURE itcsy

    output STRUCTURE itcsy.

    TABLES: lfa1, "Vendor Master (General Section)

    lfm1, "Vendor master record purchasing org.data

    t001w, "Plants

    adrct. "Address texts (central address admin.)

    CONSTANTS: c_object_type TYPE tabelle VALUE 'CRHD',

    c_classnum LIKE bapi_class_key-classnum

    VALUE 'ZSERVICELOCATION',

    c_classtype LIKE bapi_class_key-classtype

    VALUE '019',

    c_plant(12) TYPE c VALUE 'CAUFVD-WERKS',

    c_work_centre(12) TYPE c VALUE 'CAUFVD-VAPLZ',

    c_wkcnt_plant(12) TYPE c VALUE 'CAUFVD-VAWRK',

    c_vend_number(7) TYPE c VALUE 'SRVNUMB',

    c_vend_name(7) TYPE c VALUE 'SRVNAME',

    c_vend_street(7) TYPE c VALUE 'SRVSTRT',

    c_vend_region(7) TYPE c VALUE 'SRVREGN',

    c_vend_pstcode(7) TYPE c VALUE 'SRVPCDE',

    c_vend_telf1(7) TYPE c VALUE 'SRVTELF',

    c_vend_fax(7) TYPE c VALUE 'SRVFAXN',

    c_vend_contact(7) TYPE c VALUE 'SRVCNME',

    c_vend_mob(7) TYPE c VALUE 'SRVMOBL',

    c_name_char TYPE atnam VALUE 'ZVENDORNO'.

    DATA: v_object_key LIKE bapi_class_objects-object_key,

    v_plant_value LIKE itcsy-value,

    v_wk_cntr_value LIKE itcsy-value,

    v_wk_plant_value LIKE itcsy-value,

    v_lifnr LIKE lfa1-lifnr,

    t_objects LIKE bapi_class_objects OCCURS 0 WITH HEADER LINE,

    t_assigned_values LIKE bapi_object_values

    OCCURS 0 WITH HEADER LINE,

    s_return LIKE bapireturn1.

    • read value of Plant and move to a variable

    READ TABLE input WITH KEY c_plant.

    IF sy-subrc = 0.

    v_plant_value = input-value.

    ENDIF.

    • read value of Work Centre Plant and move to a variable

    READ TABLE input WITH KEY c_wkcnt_plant.

    CHECK sy-subrc = 0.

    v_wk_plant_value = input-value.

    • read value of Work Centre and move to a variable

    READ TABLE input WITH KEY c_work_centre.

    CHECK sy-subrc = 0.

    v_wk_cntr_value = input-value.

    • build the object key

    CONCATENATE v_wk_plant_value v_wk_cntr_value INTO v_object_key.

    • add entry to class objects table for passing to BAPI

    t_objects-object_key = v_object_key.

    t_objects-object_type = c_object_type.

    APPEND t_objects.

    • retrieve the values of classification objects for the class

    CALL FUNCTION 'BAPI_CLASS_GET_CLASSIFICATIONS'

    EXPORTING

    classtype = c_classtype

    classnum = c_classnum

    key_date = sy-datum

    IMPORTING

    return = s_return

    TABLES

    object_classification = t_assigned_values

    class_objects = t_objects.

    • BAPI call must be successful

    CHECK s_return-type <> 'E'.

    • read the Vendor number value from the table

    READ TABLE t_assigned_values WITH KEY name_char = c_name_char.

    CHECK sy-subrc = 0.

    • convert vendor no. to internal format

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    input = t_assigned_values-char_value

    IMPORTING

    output = v_lifnr.

    • get vendor details from vendor master

    SELECT SINGLE * FROM lfa1 WHERE lifnr = v_lifnr.

    CHECK sy-subrc = 0.

    • pass & modify the values to transfer table back to SAPSCRIPT

    LOOP AT output.

    CASE output-name.

    WHEN c_vend_number.

    SHIFT v_lifnr LEFT DELETING LEADING '0'.

    output-value = v_lifnr.

    WHEN c_vend_name.

    output-value = lfa1-name1.

    WHEN c_vend_street.

    CONCATENATE lfa1-stras lfa1-ort01 INTO output-value

    SEPARATED BY ', '.

    WHEN c_vend_region.

    output-value = lfa1-regio.

    WHEN c_vend_pstcode.

    output-value = lfa1-pstlz.

    WHEN c_vend_telf1.

    output-value = lfa1-telf1.

    WHEN c_vend_fax.

    output-value = lfa1-telfx.

    WHEN c_vend_contact.

    PERFORM get_lfm1 USING lfa1-lifnr 'N'

    v_plant_value

    CHANGING output-value.

    WHEN c_vend_mob.

    • PERFORM get_adrct USING lfa1-adrnr

    • CHANGING output-value.

    PERFORM get_lfm1 USING lfa1-lifnr 'M'

    v_plant_value

    CHANGING output-value.

    WHEN OTHERS.

    ENDCASE.

    MODIFY output INDEX sy-tabix.

    ENDLOOP.

    ENDFORM.

    &----


    *& Form get_adrct

    &----


    FORM get_adrct USING p_adrnr

    CHANGING p_value.

    SELECT SINGLE remark FROM adrct INTO adrct-remark

    WHERE addrnumber = p_adrnr

    AND date_from <= sy-datum

    AND langu = sy-langu.

    CHECK sy-subrc = 0.

    p_value = adrct-remark.

    ENDFORM. " get_adrct

    ----


    • FORM GET_WORK_CENTRE *

    ----


    • Get Work Centre/Plant from the Order *

    ----


    • --> INPUT *

    • --> OUTPUT *

    ----


    FORM get_work_centre TABLES input STRUCTURE itcsy

    output STRUCTURE itcsy.

    TABLES: afih,

    crhd.

    CONSTANTS: c_order_no(10) TYPE c VALUE 'MSEG-AUFNR',

    c_work_centre(12) TYPE c VALUE 'CAUFVD-VAPLZ',

    c_plant(12) TYPE c VALUE 'CAUFVD-VAWRK'.

    DATA: v_order_no TYPE aufnr,

    v_work_centre LIKE crhd-arbpl,

    v_plant LIKE crhd-werks.

    • read value of Order number and move to a variable

    READ TABLE input WITH KEY c_order_no.

    CHECK sy-subrc = 0.

    v_order_no = input-value.

    • convert Order Number to internal format

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    input = v_order_no

    IMPORTING

    output = v_order_no.

    • read Work Centre number & Plant values for the order

    SELECT SINGLE iwerk pm_objty gewrk FROM afih

    INTO (v_plant, afih-pm_objty, afih-gewrk)

    WHERE aufnr = v_order_no.

    CHECK sy-subrc = 0.

    SELECT SINGLE arbpl FROM crhd

    INTO v_work_centre

    WHERE objty = afih-pm_objty

    AND objid = afih-gewrk.

    CHECK sy-subrc = 0.

    • pass & modify the values to transfer table back to SAPSCRIPT

    LOOP AT output.

    CASE output-name.

    WHEN c_plant.

    output-value = v_plant.

    WHEN c_work_centre.

    output-value = v_work_centre.

    ENDCASE.

    MODIFY output INDEX sy-tabix.

    ENDLOOP.

    ENDFORM.

    &----


    *& Form get_lfm1

    &----


    • Get Vendor Contact Person Name OR Mobile Number

    ----


    FORM get_lfm1 USING p_lifnr

    p_par

    p_plant

    CHANGING p_value.

    CHECK NOT p_lifnr IS INITIAL AND

    NOT p_plant IS INITIAL.

    SELECT SINGLE ekorg FROM t001w

    INTO t001w-ekorg

    WHERE werks = p_plant.

    CHECK sy-subrc = 0.

    SELECT SINGLE verkf telf1 FROM lfm1

    INTO (lfm1-verkf, lfm1-telf1)

    WHERE lifnr = p_lifnr

    AND ekorg = t001w-ekorg.

    CHECK sy-subrc = 0.

    CASE p_par.

    WHEN 'M'.

    p_value = lfm1-telf1.

    WHEN 'N'.

    p_value = lfm1-verkf.

    WHEN OTHERS.

    ENDCASE.

    ENDFORM.

    Regards,

    Sougata.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.