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

Script: Subroutine pool.

Hi experts,

Please help me how to write subroutine pool .for this fields.

REGUH-VBLNR

REGUH-LAUFD,

REGUH-LAUFI

REGUH-UBKNT

OR GIVE ME ONE EXAMPLE WITH ONE OF THESE FIELDS I WILL DO THE REST.

\[removed by moderator\]

Regards,

sunita

Edited by: Jan Stallkamp on Jul 25, 2008 11:00 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2008 at 03:50 AM

    Hi,

    Subroutines in scripts are generally used to pass some additional values into scripts without having to modify the standard programs.

    Try the following code,

    In your script write the following,

    /:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK
    
    /:USING &EKKO-EBELN&
    
    /:CHANGING &CDECENT&
    
    /:ENDPERFORM 
    

    In the program write the following code,

    REPORT zkrpmm_perform_z1medruck .
    DATA : BEGIN OF it_input_table OCCURS 10.
            INCLUDE STRUCTURE itcsy.
    DATA : END OF it_input_table.
    * déclaration de la table output_table contenant les
    variables exportées
    DATA : BEGIN OF it_output_table OCCURS 0.
            INCLUDE STRUCTURE itcsy.
    DATA : END OF it_output_table.
    
    DATA : w_ebeln LIKE ekko-ebeln,
    *       w_vbeln LIKE vbak-vbeln,
           w_zcdffa LIKE vbak-zcdffa.
    
    *-----------------------------------------------------*
    *  FORM CDE_CENT
    *
    *-----------------------------------------------------*
    FORM cde_cent TABLES input output.
    
      it_input_table[] = input[].
      it_output_table[] = output[].
    
      READ TABLE it_input_table INDEX 1.
      MOVE it_input_table-value TO w_ebeln.
    
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
           EXPORTING
                input  = w_ebeln
           IMPORTING
                output = w_ebeln.
    
      SELECT SINGLE zcdffa FROM ekko
      INTO w_zcdffa
      WHERE ebeln = w_ebeln.
    
      it_output_table-name = 'CDECENT'.
      MOVE w_zcdffa TO it_output_table-value.
      MODIFY it_output_table INDEX 1.
    
      output[] = it_output_table[].
    
    ENDFORM.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2008 at 04:03 AM

    Hi,

    see below ex:

    Calling ABAP Subroutines: PERFORM

    You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.

    PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.

    Syntax in a form window:

    /: PERFORM <form> IN PROGRAM <prog>

    /: USING &INVAR1&

    /: USING &INVAR2&

    ......

    /: CHANGING &OUTVAR1&

    /: CHANGING &OUTVAR2&

    ......

    /: ENDPERFORM

    INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.

    OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.

    The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:

    FORM <form> TABLES IN_TAB STRUCTURE ITCSY

    OUT_TAB STRUCTURE ITCSY.

    ...

    ENDFORM.

    The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.

    The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.

    From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (u2018First pageu2019, u2018Next pageu2019, u2018Last pageu2019) is printed as local variable symbol.

    Definition in the SAPscript form:

    /: PERFORM GET_BARCODE IN PROGRAM QCJPERFO

    /: USING &PAGE&

    /: USING &NEXTPAGE&

    /: CHANGING &BARCODE&

    /: ENDPERFORM

    /

    / &BARCODE&

    Coding of the calling ABAP program:

    REPORT QCJPERFO.

    FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY

    OUT_PAR STRUCTURE ITCSY.

    DATA: PAGNUM LIKE SY-TABIX, "page number

    NEXTPAGE LIKE SY-TABIX. "number of next page

    READ TABLE IN_PAR WITH KEY u2018PAGEu2019.

    CHECK SY-SUBRC = 0.

    PAGNUM = IN_PAR-VALUE.

    READ TABLE IN_PAR WITH KEY u2018NEXTPAGEu2019.

    CHECK SY-SUBRC = 0.

    NEXTPAGE = IN_PAR-VALUE.

    READ TABLE IN_PAR WITH KEY u2018BARCODEu2019.

    CHECK SY-SUBRC = 0.

    IF PAGNUM = 1.

    OUT_PAR-VALUE = u2018|u2019. "First page

    ELSE.

    OUT_PAR-VALUE = u2018||u2019. "Next page

    ENDIF.

    IF NEXTPAGE = 0.

    OUT_PAR-VALUE+2 = u2018Lu2019. "Flag: last page

    ENDIF.

    MODIFY OUT_PAR INDEX SY-TABIX.

    ENDFORM.

    hope it will help..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2008 at 04:16 AM

    Hi ,

    Use this in sap script....

    Syntax in a form window:

    /: PERFORM <form> IN PROGRAM <prog>

    /: USING &VAR1&

    /: USING &VAR2&

    ......

    /: CHANGING &OUTPUT1&

    /: CHANGING &OUTPUT2&

    ......

    /: ENDPERFORM.

    Syntax in program.....

    form <form> intab structure itcsy outtab structure itcsy.

    read table intab index 1.

    if sy-subrc eq 0.

    l_var1 = intab-value.

    endif.

    read table intab index 2.

    if sy-subrc eq 0.

    l_var2 = intab-value.

    endif.

    ...

    ....

    do coding as per your requirement....

    ...

    read table outtab index 1.

    if sy-subrc = 0.

    outtab-value = l_output1.

    modify outtab index 1.

    endif.

    read table outtab index 2.

    if sy-subrc = 0.

    outtab-value = l_output2.

    modify outtab index 2.

    endif.

    Hope this solve your question...

    Please reward point if usefull.

    Regards,

    Smit

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2008 at 04:16 AM

    Hi Sunitha,

    You can do this :

    Code to be written in the Form Editor:

    /:DEFINE &CUST& = '00000021'.

    /:PERFORM GET_NAME IN PROGRAM Z_BC460_EX4_HF

    /: USING &CUST&

    /: CHANGING &NAME&

    /:ENDPERFORM.

    Code to be written in the Program :

    REPORT Z_HENRIKF_SCRIPT_FORM .

    TABLES scustom.

    FORM get_name tables in_tab structure itcsy out_tab structure itcsy.

    read table in_tab index 1.

    select single * from scustom

    where id = in_tab-value.

    if sy-subrc = 0.

    read table out_tab index 1.

    move scustom-name to out_tab-value.

    modify out_tab index sy-tabix.

    else.

    read table out_tab index 1.

    move 'No name' to out_tab-value.

    modify out_tab index sy-tabix.

    endif.

    *

    o You could also fill the ouput parameter table this way

    • READ TABLE out_par WITH KEY 'NAME1'.

    • out_par-value = l_name1.

    • MODIFY out_par INDEX sy-tabix.

    ENDFORM.

    Regards.

    Eshwar.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2008 at 04:18 AM

    Hi Experts,

    Can any 1 give me example with the fields which i have given..

    correct answers will b appriciated with good points.

    Regards

    Sunita.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      If you want to get the following fields from a subroutine pool to your script try the following code,

      in the script,

      /:PERFORM GET_REGUH_DATA IN PROGRAM ZREGUH_TABLE_DATA
      
      /:CHANGING &VBLNR&
      
      /:ENDPERFORM 
      

      in the program,

      REPORT ZREGUH_TABLE_DATA.
      
      DATA : BEGIN OF it_output_table OCCURS 0.
              INCLUDE STRUCTURE itcsy.
      DATA : END OF it_output_table.
      
      DATA : w_vblnr LIKE REGUH-VBLNR.
      
      FORM GET_REGUH_DATA tables OUTPUT.
      
      SELECT VBLNR
         FROM REGUH
         INTO   (w_vblnr)
         UP TO 1 ROW.
      
      it_output_table-name = 'VBLNR'.
      MOVE w_vblnr TO it_output_table-value.
      MODIFY it_output_table INDEX 1.
      
      output[] = it_output_table[]
      
      ENDFORM.
      

      Try the following link for more detailed information on creating a subroutine for SAP Scripts,

      [http://www.saptechnical.com/Tutorials/Smartforms/PassingTableData/Script1.htm]

  • Posted on Jul 25, 2008 at 09:10 AM

    Hi,

    which field value u want from the fields u specified.

    Regards,

    Krishna

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2008 at 09:22 AM

    Hi Sunita,

    In the script SE71,

    /: Define &REGUH-VBLNR& = ' '

    /: Define &L_VAL& = ' '

    /:PERFORM GET_DATA IN PROGRAM ZTABLE_DATA

    /: USING &L_VAL&(you need some link for subroutine from program if you have it then ok unless ignore)

    /: CHANGING &REGUH-VBLNR&

    /:ENDPERFORM

    In the Report program SE38,

    REPORT ZTABLE_DATA.

    &----


    *& Form GET_DETAILS

    &----


    • -->IN_TAB text

    • -->OUT_TAB text

    ----


    FORM get_details TABLES in_tab STRUCTURE itcsy

    out_tab STRUCTURE itcsy.

    ----


    • Workareas and Variables Declaration

    ----


    DATA : l_vblnr LIKE REGUH-VBLNR,

    l_value type kunnr.

    ----


    • Reading Data From Sapscript

    ----


    READ TABLE in_tab WITH KEY name = 'L_VAL'.

    IF sy-subrc = 0 .

    MOVE in_tab-value TO l_value.

    ENDIF.

    ----


    • select Quaries

    ----


    SELECT VBLNR

    FROM REGUH

    INTO (l_vblnr)

    UP TO 1 ROW

    where kunnr Eq l_value.

    ----


    • Read subroutine parameters and store in variables.

    ----


    READ TABLE out_tab WITH KEY name = 'REGUH-VBLNR'.

    IF sy-subrc = 0 .

    MOVE l_vblnr TO out_tab-value.

    MODIFY out_tab INDEX sy-tabix.

    ENDIF.

    ENDFORM. "get_details.

    FORM GET_REGUH_DATA tables OUTPUT.

    it_output_table-name = 'VBLNR'.

    MOVE w_vblnr TO it_output_table-value.

    MODIFY it_output_table INDEX 1.

    output[] = it_output_table[]

    ENDFORM.

    hope this will help

    if not let us know the problem

    Thanks

    Ankur

    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.