Subroutines in SAP Sapcript

Hi Experts,
I want to pick up some 7 fields from different tables with one input criteria in a sap script. I tried using the subroutines for this. But the problem i am facing is that it is just returning one value. I want 7 fields.
The code is used
Perform xyz in program aaa using one
                           chaning two
                           chaning three
                           chaning four
                           chaning five.
endperform.
Same goes for the report.
form xyz tables in_par structure itcsy
                          out_par structure itcsy.
Read table in_par with key 'one'.
(select statements....
these values are stored in internal table.. or variables.)
move ITAB-one to out_par-value.
move ITAB-two to out_par-value.
move ITAB-three to out_par-value.
move ITAB-four to out_par-value.
move ITAB-five to out_par-value.
modify out_par index sy-tabix.
endform.
but here it is overwritting the value everytime and just the last thats itab-five is returned.
Any inputs to resolve this issue. If for such a requirment subroutine willnot work, then pls suggest some other solution for this.
Thanks.
NC

Hi NC,
if you call like this:
perform xyz in program aaa
  using &one&
  changing &two&
  changing &three&
  changing &four&
  changing &five&
then you should develop the following code in subroutine pool "aaa":
form xyz tables in_par structure itcsy
         tables out_par structure itcsy.
  read table in_par with key 'ONE'.
  check sy-subrc = 0.
* (select whatever you want)...
  read table out_par with key 'TWO'.
  check sy-subrc = 0.
  out_par-value = '...'.
  modify out_par index sy-tabix.
  read table out_par with key 'THREE'.
  check sy-subrc = 0.
  out_par-value = '...'.
  modify out_par index sy-tabix.
  read table out_par with key 'FOUR'.
  check sy-subrc = 0.
  out_par-value = '...'.
  modify out_par index sy-tabix.
  read table out_par with key 'FIVE'.
  check sy-subrc = 0.
  out_par-value = '...'.
  modify out_par index sy-tabix.
endform.
That is, you should read every output parameter from itab out_par, and then modify column "value" by this "modify...index sy-tabix".
Please let us know if it helped. Best regards,
Alvaro

Similar Messages

  • HOw can we Call Subroutine in Sap Script?

    HOw can we Call Subroutine in Sap Script?

    Hi
    *You have to call sub routine from script like this.
    /:   PERFORM DATE_FORMAT IN PROGRAM &SY-REPID&
    /:   USING &RM06P-LFDAT&
    /:   USING &PEKKO-LFDAT&
    /:   CHANGING &VALUE_OLD&
    /:   CHANGING &VALUE_NEW&
    /:   ENDPERFORM
    *In print program write code.
    FORM date_format TABLES in_tab STRUCTURE itcsy
    out_tab STRUCTURE itcsy.
      DATA : date TYPE char10.
      DATA : date2 TYPE char10.
      DATA : l_dmbtr TYPE char10.
      READ TABLE in_tab WITH KEY 'RM06P-LFDAT'.
      IF sy-subrc = 0.
        "Your code goes here
        CLEAR l_dmbtr.
      ENDIF.
      READ TABLE in_tab WITH KEY 'PEKKO-LFDAT'.
      IF sy-subrc = 0.
        l_dmbtr = in_tab-value.
        "Your code goes here
        CLEAR l_dmbtr.
      ENDIF.
      READ TABLE out_tab WITH KEY 'VALUE_NEW'.
        IF sy-subrc EQ 0.
            out_tab-value = date2.
            MODIFY out_tab INDEX sy-tabix.
        ENDIF.
      READ TABLE out_tab WITH KEY 'VALUE_OLD'.
        IF sy-subrc = 0.
            out_tab-value = l_dmbtr.
            MODIFY out_tab INDEX sy-tabix.
        ENDIF.
    ENDFORM.            "DATE_FORMAT

  • Call subroutine in sap script

    how can i call subroutine in SAP Script?& where?

    hi,
    refer d links
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/calling%2ba%2bsub-routine%2bin%2bsap%2bscripts
    subroutine in script. REWARDED
    abput subroutines in scripts
    How to call a subroutine in a script ?
    How to call subroutine in a sap script

  • ABAP Subroutines in SAP Script forms

    Hi Friends,
    Can any give an example on using ABAP Subroutines in SAP Scripts
    how to call ABAP  subroutine IN FORM  and how to define form statement in abap program
    thanks in advance
    Points for sure
    Regards
    Vijaya

    Hi,
    you have to write
    perform formname in program zprogram
    using  &var1&
    using &var2&
    changing &var3&
    endperform
    in se38 create program zprogram of subroutine pool ttype
    and
    write the
    form
    endform there
    egcode for  a subroutne for changing the amount into indian words
    PROGRAM  ZFII_SR_PAYMNT_CHCK.
    declaring the variables which are necessary
    DATA:
      G_AMOUNT       TYPE PC207-BETRG,          " having  amount value
      G_SPELL_AMOUNT(60)  TYPE C, " LIKE     SPELL-WORD,  " amount in words
      G_SPELL_AMOUNT1(60) TYPE C,        " spell structure
      G_WHTAX TYPE BSAK-QBSHB,   "
      G_QBSHB TYPE BSAK-QBSHB, " FOR COLLECTING THE WITH HOLDING TAX
      G_ZUMSK TYPE BSAK-ZUMSK.
    *DECLARING THE INTERNAL TABLES FOR THE OUTPUT TO BE DISPLAYED.
    TYPES : BEGIN OF T_INPUT_TABLE.
            INCLUDE STRUCTURE ITCSY.
    TYPES : END OF T_INPUT_TABLE.
    TYPES : BEGIN OF T_OUTPUT_TABLE.
            INCLUDE STRUCTURE ITCSY.
    TYPES: END OF T_OUTPUT_TABLE.
    DATA: GWA_INPUT_TABLE  TYPE T_INPUT_TABLE.
    DATA: GWA_OUTPUT_TABLE TYPE T_OUTPUT_TABLE.
    DATA: GIT_INPUT_TABLE TYPE STANDARD TABLE OF  T_INPUT_TABLE.
    DATA: GIT_OUTPUT_TABLE TYPE STANDARD  TABLE OF  T_OUTPUT_TABLE.
    TYPES : BEGIN OF T_ITEM,
              BUKRS TYPE BUKRS,
              BELNR TYPE BELNR_D,
              GJAHR TYPE GJAHR,
              WT_WITHCD TYPE WT_WITHCD,
              WT_QBSHB TYPE  WT_WT1,
             END OF T_ITEM,
           IT_T_ITEM TYPE STANDARD TABLE OF T_ITEM.
    DATA :  GIT_ITEM TYPE IT_T_ITEM,
            GWA_ITEM TYPE T_ITEM.
    GET_SPELL_AMOUNT
    FORM GET_SPELL_AMOUNT  TABLES  INPUT STRUCTURE ITCSY
                                   OUTPUT STRUCTURE ITCSY.      "#EC CALLED
    CLEARING OFF THE VARIABLE USED IN PROGRAM.
      CLEAR:  G_AMOUNT,
               G_SPELL_AMOUNT.
    *clearing the internal tables which we have used.
      CLEAR:
       GIT_INPUT_TABLE,
       GIT_OUTPUT_TABLE.
    *REFRESHING THE INTERNAL TABLES.
      REFRESH:
       GIT_INPUT_TABLE,
       GIT_OUTPUT_TABLE.
    *initially assigning the memory vaules to our internal tables.
      GIT_INPUT_TABLE[]  = INPUT[].
      GIT_OUTPUT_TABLE[] = OUTPUT[].
    *reading the table input to get the amount value.
      READ TABLE GIT_INPUT_TABLE INTO GWA_INPUT_TABLE   INDEX 1.
      IF GWA_INPUT_TABLE-VALUE CA 'X'.
        REPLACE ALL OCCURRENCES OF 'X' IN GWA_INPUT_TABLE-VALUE WITH '0'.
      ENDIF.
    *THIS IS IMPORTANT PART AS IT IS CONVERTING THE
    *CHARACTER FIELD INTO CURRENCY FIELD.
      SHIFT GWA_INPUT_TABLE-VALUE LEFT DELETING LEADING SPACE.
      TRANSLATE GWA_INPUT_TABLE-VALUE USING ', '.
      CONDENSE GWA_INPUT_TABLE-VALUE NO-GAPS.
      G_AMOUNT = GWA_INPUT_TABLE-VALUE.
    *calling the function moudle which will
    *covert amount into words (indian format ).
    *i.e in crores, lakhs, thousands
      DATA: L_SPELLAMOUNT(255) TYPE C,
            L_ONLY(255) TYPE C.
      CLEAR: L_SPELLAMOUNT, L_ONLY.
    *here the amount should not be more than
    99,99,99,999.99 . if it is greater than
    *this amount this function module will not work
    *so give the amount which is lessthan or equal to
    *above said amount.
      IF G_AMOUNT LT '1000000000'.
        CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
          EXPORTING
            AMT_IN_NUM         = G_AMOUNT
          IMPORTING
            AMT_IN_WORDS       = L_SPELLAMOUNT
          EXCEPTIONS
            DATA_TYPE_MISMATCH = 1
            OTHERS             = 2.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
      CONDENSE L_SPELLAMOUNT.
      TRANSLATE L_SPELLAMOUNT TO UPPER CASE.
      CONCATENATE L_SPELLAMOUNT 'ONLY' INTO L_ONLY SEPARATED BY SPACE.
    *moivng the field name into table field.
      GWA_OUTPUT_TABLE-NAME = 'G_SPELL_AMOUNT'.
    *assigning the amount in words to the variable.
    *the reason  behind splitting the word into two parts
    *is--- in the scripts the whole string is not getting
    *printed. So we are splitting it into two parts so that
    *it will print the whole string.
      G_SPELL_AMOUNT = L_ONLY+0(60).
      G_SPELL_AMOUNT1 = L_ONLY+60(60).
    G_SPELL_AMOUNT  = L_SPELLAMOUNT.
    *MOVING THE AMOUNT IN WORDS TO FINAL WORK AREA.
      MOVE G_SPELL_AMOUNT TO GWA_OUTPUT_TABLE-VALUE.
    *MODIFYING THE INTERNAL TABLE FORM THE WORK AREA.
      MODIFY  GIT_OUTPUT_TABLE FROM GWA_OUTPUT_TABLE INDEX 1.
    *FOR THE SECOND RECORD I.E FOR THE NEXT 60characters
      GWA_OUTPUT_TABLE-NAME = 'G_SPELL_AMOUNT1'.
      MOVE G_SPELL_AMOUNT1 TO GWA_OUTPUT_TABLE-VALUE.
      MODIFY  GIT_OUTPUT_TABLE FROM GWA_OUTPUT_TABLE INDEX 2.
    *assigning the total output table to the memory .
      OUTPUT[] =  GIT_OUTPUT_TABLE[].
    ENDFORM.                    "GET_COMPADDR
    thanks & regards,
    Venkatesh

  • How to call a subroutine from sap script

    hi friends,
    Can anybody tell me How to call a subroutine from sap script .
    thanks n regards .
    Mahesh

    hi..
    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.
    The system does not execute the PERFORM command within SAPscript replace modules, such as TEXT_SYMBOL_REPLACE or TEXT_INCLUDE_REPLACE. The replace modules can only replace symbol values or resolve include texts, but not interpret SAPscript control commands.
    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 (‘First page’, ‘Next page’, ‘Last page’) 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 ‘PAGE’.
    CHECK SY-SUBRC = 0.
    PAGNUM = IN_PAR-VALUE.
    READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.
    CHECK SY-SUBRC = 0.
    NEXTPAGE = IN_PAR-VALUE.
    READ TABLE OUT_PAR WITH KEY ‘BARCODE’.
    CHECK SY-SUBRC = 0.
    IF PAGNUM = 1.
    OUT_PAR-VALUE = ‘|’. "First page
    ELSE.
    OUT_PAR-VALUE = ‘||’. "Next page
    ENDIF.
    IF NEXTPAGE = 0.
    OUT_PAR-VALUE+2 = ‘L’. "Flag: last page
    ENDIF.
    MODIFY OUT_PAR INDEX SY-TABIX.
    ENDFORM.
    regards,
    veeresh

  • How 2 debug a Perform subroutine in sap script

    Hi,
    I have a perform endperform in Script. But tht is not working in some case. i m trying to debug but i m not able to go inside the routine and see wht it is doing? . can any one help me how to debug a subroutine in sap script.

    Hi Panigrahi,
    1) Put a break point in your perform.
    2)  YOu should change the dispatch option in your Output screen of the transaction which triggers your sap script. The dispatch option should be 1 (Send with a periodically scheduled job).
    Then save your transaction.
    3) Go to se38 and run the program RSNAST00.
    Give the Object Key as the Document Number for which you are triggering the script output.
    The control will stop in your perform.
    Regards,
    Ravi

  • Using Subroutines in SAP script

    Hi Experts,
    I am trying to get value of Z variables from a subroutine pool program using Perform ... EndPerform in my sap script form.
    In my form window i have written
    PERFORM ITEM_LINE_2F IN PROGRAM ZMEPRINTFORMS
    USING &EKPO-MENGE&
    CHANGING &V_EKPO_MENGE&
    ENDPERFORM
    and in my subroutine pool program i have written:
    FORM ITEM_LINE_2F TABLES IN_PAR STRUCTURE ITCSY
                                                  out_par structure itcsy.
    data :  ZLV_ekpo_menge(17),
              v_ekpo_menge(17),
             ZLV_temp_split_1(14),
             ZLV_temp_split_2(3),
             ZLV_temp_menge(8) type p.
    constants: zc_menge type TDTPRGNAME value 'EKPO-MENGE'.
    field-symbols: <tab> type itcsy.
      loop at in_par assigning <tab>.
        case <tab>-name.
          when zc_menge.
            zlv_ekpo_menge = <tab>-value.
          when others.
        endcase.
      endloop.
      unassign <tab>.
      V_EKPO_MENGE = zlv_ekpo_menge.
      SPLIT V_EKPO_MENGE AT '.' INTO ZLV_TEMP_SPLIT_1 ZLV_TEMP_SPLIT_2.
      IF ZLV_TEMP_SPLIT_2+0(3) = '000'.
        ZLV_TEMP_MENGE = zlv_ekpo_menge.
        WRITE ZLV_TEMP_MENGE TO V_EKPO_MENGE.
      ELSE.
        WRITE zlv_ekpo_MENGE TO V_EKPO_MENGE.
      ENDIF.
      loop at out_par assigning <tab>.
        case <tab>-name.
          when V_EKPO_MENGE.
            <tab>-value = v_ekpo_menge.
          when others.
           Modify out_par.
        endcase.
      endloop.
      unassign <tab>.

    hi,
    FORM ITEM_LINE_2F TABLES IN_PAR STRUCTURE ITCSY
    out_par structure itcsy.
    data : ZLV_ekpo_menge(17),
    v_ekpo_menge(17),
    ZLV_temp_split_1(14),
    ZLV_temp_split_2(3),
    ZLV_temp_menge(8) type p.
    read table in_par index 1.
    V_EKPO_MENGE = zlv_ekpo_menge = in_par-value.
    SPLIT V_EKPO_MENGE AT '.' INTO ZLV_TEMP_SPLIT_1 ZLV_TEMP_SPLIT_2.
    IF ZLV_TEMP_SPLIT_2+0(3) = '000'.
    ZLV_TEMP_MENGE = zlv_ekpo_menge.
    WRITE ZLV_TEMP_MENGE TO V_EKPO_MENGE.
    ELSE.
    WRITE zlv_ekpo_MENGE TO V_EKPO_MENGE.
    ENDIF.
    read table out_par index 1.
    out_par-value = v_ekpo_menge.
    Modify out_par.
    but frankly speaking... i dint understand your logic... finally you are passing the same value ????????
    regards
    padma

  • Calling subroutine from SAP script

    I am using the below code within my SAP script form that prints GR/GI Slips but its not working.  And the only way I can issue the output is from MB02 whcih doesn't seem to allow to call the debuger, so I'm at a lost as to what to do.
    Code in SAP script
    /:           PERFORM GET_BINS IN PROGRAM ZMM_SAPSCRIPT_FORMS                                                                               
    USING &MSEG-MATNR&
    /:                                                           USING &MSEG-LGNUM&
    /:                                                           CHANGING &MABDR-LGPBE&
    /:           ENDPERFORM
    CODE from my subroutine program:
    FORM get_bins TABLES input_table STRUCTURE itcsy
                         output_table STRUCTURE itcsy.
      DATA: lc_matnr    TYPE matnr,
            lc_lgnum    TYPE lgnum,
            lc_lgpla    TYPE lgpla,
            lc_index    TYPE sy-tabix.
    * Material no
      READ TABLE input_table WITH KEY name = 'MSEG-MATNR'.
      MOVE input_table-value TO lc_matnr.
    * Warehouse number
      READ TABLE input_table WITH KEY name = 'MSEG-LGNUM'.
      MOVE input_table-value TO lc_lgnum.
    * Get BIN
      SELECT SINGLE lgpla INTO lc_lgpla
             FROM mlgt
             WHERE matnr = lc_matnr
             AND   lgnum = 'CPT'  "lc_lgnum
             AND   lgtyp = '001'.
      IF sy-subrc = 0.
        READ TABLE output_table WITH KEY name = 'MABDR-LGPBE'.
        lc_index = sy-tabix.
        MOVE lc_lgpla TO output_table-value.
        MODIFY output_table INDEX lc_index.
      ENDIF.

    /:           PERFORM GET_BINS IN PROGRAM ZMM_SAPSCRIPT_FORMS
    /:                                                              USING &MSEG-MATNR&
    /:                                                           USING &MSEG-LGNUM&
    /:                                                           CHANGING &MABDR-LGPBE&
    /:           ENDPERFORM
    FORM get_bins TABLES input_table STRUCTURE itcsy
                         output_table STRUCTURE itcsy.
      DATA: lc_matnr    TYPE matnr,
            lc_lgnum    TYPE lgnum,
            lc_lgpla    TYPE lgpla,
            lc_index    TYPE sy-tabix.
    Material no
      READ TABLE input_table WITH KEY name = 'MSEG-MATNR'.
      MOVE input_table-value TO lc_matnr.
    Warehouse number
      READ TABLE input_table WITH KEY name = 'MSEG-LGNUM'.
      MOVE input_table-value TO lc_lgnum.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = lc_matnr
      IMPORTING
       OUTPUT        = lc_matnr         .
    Get BIN
      SELECT SINGLE lgpla INTO lc_lgpla
             FROM mlgt
             WHERE matnr = lc_matnr
             AND   lgnum = 'CPT'  "lc_lgnum
             AND   lgtyp = '001'.
      IF sy-subrc = 0.
        READ TABLE output_table WITH KEY name = 'MABDR-LGPBE'.
        lc_index = sy-tabix.
        MOVE lc_lgpla TO output_table-value.
        MODIFY output_table TRANSPORTING VALUE WHERE NAME = 'MABDR-LGPBE'.
      ENDIF.

  • Regarding subroutine (Form-EndForm)

    How do I trigger a Subroutine ( It creates a new ticket/insurance claim number/Invoice number) only when print command is given and not when print preview is given so that un-necessarily new ticket/claim/invoice NUMBERS are not generated?

     Hi,
    So it is a script or the smartform ?
    In the sap script you can call the perform as shown below
    You could make a condition to call the below subroutine in sap script window editor.
    Example:  if sy-ucomm = 'PRINT '.
                      perform  TABLES fp_it_intab STRUCTURE itcsy      
                                            fp_it_outtab STRUCTURE itcsy.
    Endform.
     Please let me know if you want the fuction code for print command.
    Edited by: Ashwin Kumar Chitram on Oct 1, 2011 7:21 AM

  • EXPERTS PLZ HELP ME IN SAP SCRIPT URGENT

    Hi experts
    plz help me
    i m very new in sap scripts
    i have a script WESCHEINVERS1 and the driver prog is SAPM07DR
    i ill have to copy this script and have to add two more feild in the text element W1LGMAT
    fields are :
    CAWNT-ATWTB
    EKPO-REVLV
    now wat i think i cannot make changes to standard driver prog so it wud be better to call a subroutine 4 it
    so plz guide me how i ill have to fetch data nd pass to the script
    plz write the code if possible 4 u
    FYI:
    MSEG : Document Segment Material
    MANDT     Client
    MBLNR     Number of material Document
    MJAHR     Material Document Year
    ZEILE     Item in Material Document
    MATNR     Material Number
    LIFNR     Account number or vendor
    EBELN     Purchase order number
    EBELP     Item number of PO
    EKPO : Purchasing document item
    MANDT     Client
    EBELN     Purchase order number
    EBELP     Item number of PO
    MATNR     Material Number
    REVLV     Revision Level
    LFA1 : Vendor Master (General section)
    MANDT     Client     
    LIFNR     Account number of vendor or creditor     MSEG-LIFNR
    SPRAS     Language key     
    AUSP : Characteristic Values
    MANDT     Client     
    OBJEK     Key of object to be classified     MSEG-MATNR
    ATINN     Internal characteristic     ZO-QUALITY-LEVEL
    ATZHL     Internal counter     
    ATWRT     Characteristic Value     
    CAWNT : Value texts
    MANDT     Client     
    ATINN     Internal characteristic     ZO-QUALITY-LEVEL
    ATZHL     Internal counter     AUSP-ATZHL
    SPRAS     Language Key      LFA1-SPRAS
    ATWTB     Characteristic Value Description     
    thanks in advance

    Refer the links to know about calling subroutines ins cript -
    subroutine in script
    How to call a subroutine in a script ?
    EXTERNAL SUBROUTINE IN SAP SCRIPT
    Regards,
    Amit
    Reward all helpful replies.

  • About subroutine

    hi, all
      how can i use subroutine in sap script?
      thanks

    Hi,
           We know that some scripts will have driver program as SAP standard programs.Where we do not have much flexibility to modify a/c to our needs.So by using subroutines we can do the needful madifications. Let's say u need to display some value which is not coming from that driver program.But you can't w rite select like command statements in script....So to get the needed values for you u need to write a subrotuine..It is same as any se38 prograM.Just u have to  mention that the type of program is subroutine..let say u have written z_sub_rou_test as subrouitne program and z_sub_rou as form in that.. ...where it will take values from script....and send back the needed vales to the script...between which u can do coding according to your requirtements..likew riting select statements using fm's..etc....get the needed value from that and send back that to script...sothat u can sue that in u r output.
         In script  u just have to write
    /: perform 'z_sub_rou' in program  in program z_sub_rou_test using &var1& &var2&  changing &var3&...these var 1 and var 2 u alerday have in u r hand..coming from actual driving program....send these to u r subrotuinepool and do the needed coding using them..get the values into var3.
           In the below i am sending a sample code....the case is we are egtting date format in one way let's say dd/mm/yyyy but we need in dd/mmm/yy...for that we need to find the date mode coming from actual driver program and we ahve to change that mode to the needed way.
       ===========================================================
    ================ In SCRIPT ===================================
    ===========================================================
    Code added to print date format on output **************************
    PERFORM DATE_FORMAT IN PROGRAM ZGLSTPPUSX_PO_FORMS
    USING &EKKO-EBELN&
    USING &EKKO-SPRAS&
    CHANGING &DATE_FORMAT&
    ENDPERFORM
    <Z>(&DATE_FORMAT&)</>
    ===========================================================
    ================ In SCRIPT ===================================
    ===========================================================
    ===========================================================
    ================ In SUBROUTINE POOL  ========================
    ===========================================================
    this DATE_FORMAT form is in  ZGLSTPPUSX_PO_FORMS program.
    **&      Form  DATE_FORMAT
          text
         -->IN_TAB     text
         -->OUT_TAB    text
    *FORM date_format
        TABLES in_tab  STRUCTURE itcsy
               out_tab STRUCTURE itcsy.
    TYPES: BEGIN OF ty_datfm,
               domname   TYPE char30,
               valpos    TYPE numc4,
               ddlanguage TYPE SPRAS,
               domvalue_l    TYPE char10,
               domvalue_h  TYPE char10,
               dontext(60)  TYPE c,
               domval_ld TYPE char10,
               domval_hd TYPE char10,
             END OF ty_datfm.
    DATA: i_datfm   TYPE  STANDARD TABLE OF DD07V
                       INITIAL SIZE 0. " Internal table for datfm
    DATA: r_datfm  TYPE DD07V. " Work area for datfm
    DATA:  l_v_ebeln LIKE ekko-ebeln.
    DATA:  l_v_spras TYPE spras.
    DATA:  l_v_land1 TYPE land1_gp.
    DATA:  l_v_oa_vendor LIKE ekpa-lifn2.
    DATA:  l_v_datfm TYPE datfm.
    DATA:  l_k_datfm TYPE char30 VALUE 'DATFM'.
    DATA:  l_k_text(60) TYPE c.
    READ TABLE in_tab INDEX 1.
    l_v_ebeln = in_tab-value.
    READ TABLE in_tab INDEX 2.
    l_v_spras = in_tab-value.
    SELECT SINGLE lifn2
       INTO l_v_oa_vendor
       FROM ekpa
       WHERE ebeln = l_v_ebeln AND
             parvw = 'BA'.      " OA partner function
    CHECK sy-subrc = 0.
    SELECT SINGLE land1
       INTO l_v_land1
       FROM lfa1
       WHERE lifnr = l_v_oa_vendor.
    CHECK sy-subrc = 0.
    SELECT SINGLE datfm
        INTO l_v_datfm
        FROM t005x
        WHERE land = l_v_land1.
    CALL FUNCTION 'DDIF_DOMA_GET'
       EXPORTING
         name                = l_k_datfm
         state               = 'A'
         langu               =  l_v_spras
         IMPORTING
           GOTSTATE            =
           DD01V_WA            =
      TABLES
        dd07v_tab           =  i_datfm
      EXCEPTIONS
        illegal_input       = 1
        OTHERS              = 2.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    READ TABLE i_datfm INTO r_datfm
                    WITH key domvalue_l = l_v_datfm
                             ddlanguage = l_v_spras.
    IF sy-subrc = 0.
       l_K_text = r_datfm-ddtext.
    ENDIF.
    READ TABLE out_tab INDEX 1.
    WRITE l_k_text TO out_tab-value .
    MODIFY out_tab INDEX 1.
    *ENDFORM.                    "date_format
    ===========================================================
    ================ In SUBROUTINE POOL  ========================
    ===========================================================

  • Online test questions... plz  provide answers

    How can we copy a standard table to make our own z_table?
    By using the copy option in SE11.
    By using include structure command.
    By using Append structure command.
    By Copying the entire structure of the standard table in our new table.
    In reporting tell me all the events in a sequentail order
    1- Initialization.
    2- At Selection-Screen
    3- Start-of-Selection.
    4- Top-of-Page.
    5- AT PF-Status
    6- End-of-Page.
    7- End-of-Selection.
    1, 2, 3, 4, 5, 6, 7.
    1, 2, 3, 7, 4, 6, 5.
    1, 2, 3, 7, 4, 5, 6.
    1, 2, 3, 6, 4, 5, 7.
    Can we create an ABAP program without using Y or Z?
    YES
    NO
    Which is not a dml statement in sap?
    Update. 
    Append.
    Insert. 
    Delete. 
    What are different data types in ABAP/4?
    Userdefined TYPES. 
    User defined TYPES as well as C,D,F,I,N,P,T,X.
    C,D,F,I,N,P,T,X only
    Only SAP defined types.
    What are the types of tables?
    Transparent table, Pool table and cluster table, Data dictionary table objects sorted table, indexed table and hash table. 
    All of the options
    Transparent table, Pool table and cluster table.
    Data dictionary table objects sorted table, indexed table and hash table.
    When is top of the page event triggered?
    Whenever a new page is triggered
    After excuteing first write statement in start-of-selection event. 
    In all the cases.
    Immediately after the End of selection
    Command 'SUM' would add fields of type N,I only.
    False
    True
    What is the system field for getting present date?
    sy-tabix.
    sy-datum.
    sy-pageno.
    sy-index.
    What is the difference between internal and external subroutines?
    Internal subroutines are SAP defined RFCs and External subroutines are Non SAP defined RFCs
    It is the same.
    External subroutines are used in Non SAP programs.
    Internal subroutines are what are declared inside the program and external subroutines are what are declared outside the program and referred from outside the program.
    How can we create field without data element?
    By directly referring to type of the field.
    We will not be able to create field without a data element
    By using direct type option in SE11
    By using Data element option in SE11.
    What is the purpose of SM30?
    SM30 is a table maintanance for the custom tables as well as database tables.
    None of the options.
    Transaction to create custom table.
    SM30 is a table maintanance for the custom tables created by us. 
    What is the difference between selection screen elements and text elements?
    Selection screen elements can only be used for the purpose of display names in selection screen wheareas text elements are reusable and dynamic text definition which can be used across the program.
    Text elements are static whereas selection screen elements are dynamic
    Both can be used to define a text definition and can be used in the entire program.
    Selection screen elements can only be used for the purpose of display names in selection screen wheareas text elements are reusable and dynamic text definition which can be used across the program other than selection screen.
    Local Variables cab be used in the whole program but not outside the program it is defined.
    True
    False
    What is the different between clear and refresh?
    Clear is used to clear the work area whereas Refresh to clear the contents of database or internal table.
    Clear is used to clear the header content whereas Refresh is used to clear the contents of internal tables.
    Both does the same. 
    Depending on the internal table declaration, either clear or refresh is used.
    How many indexes can be created for a table?
    9
    1
    As many as required.
    4
    How to access the logic coded in a program other than the one you are coding in?
    By using SUBMIT command.
    All of the options are valid.
    By using CALL PROGRAM command.
    By using INCLUDE command
    What is data class?
    The data class specifies in which table space the table is created in database.
    All of the options. 
    The data class specifies what table type is created in database. 
    The data class specifies what size table is created in database. 
    For concatenating variables, variables must be of type..
    Character or String only.
    Variables of all types can be concatenated.
    Character type only.
    String only.
    <b> ASSURE REWARD FOR ANSWERS </b>
    THANK YOU

    hi rajesh,
    How can we copy a standard table to make our own z_table?
    By using the copy option in SE11. -
    >
    By using include structure command.
    By using Append structure command.
    By Copying the entire structure of the standard table in our new table.
    In reporting tell me all the events in a sequentail order
    1- Initialization.
    2- At Selection-Screen
    3- Start-of-Selection.
    4- Top-of-Page.
    5- AT PF-Status
    6- End-of-Page.
    7- End-of-Selection.
    1, 2, 3, 4, 5, 6, 7.
    1, 2, 3, 7, 4, 6, 5. -
    >
    1, 2, 3, 7, 4, 5, 6.
    1, 2, 3, 6, 4, 5, 7.
    Can we create an ABAP program without using Y or Z?
    YES
    NO -
    >
    Which is not a dml statement in sap?
    Update.
    Append.----
    >
    Insert.
    Delete.
    What are different data types in ABAP/4?
    Userdefined TYPES.
    User defined TYPES as well as C,D,F,I,N,P,T,X.
    C,D,F,I,N,P,T,X only -
    > not sure
    Only SAP defined types.
    What are the types of tables?
    Transparent table, Pool table and cluster table, Data dictionary table objects sorted table, indexed table and hash table.
    All of the options
    Transparent table, Pool table and cluster table. -
    >
    Data dictionary table objects sorted table, indexed table and hash table.
    When is top of the page event triggered?
    Whenever a new page is triggered -
    >
    After excuteing first write statement in start-of-selection event.
    In all the cases.
    Immediately after the End of selection
    Command 'SUM' would add fields of type N,I only.
    False -
    >
    True
    What is the system field for getting present date?
    sy-tabix.
    sy-datum. -
    >
    sy-pageno.
    sy-index.
    What is the difference between internal and external subroutines?
    Internal subroutines are SAP defined RFCs and External subroutines are Non SAP defined RFCs
    It is the same.
    External subroutines are used in Non SAP programs.
    Internal subroutines are what are declared inside the program and external subroutines are what are declared outside the program and referred from outside the program.----
    >
    How can we create field without data element?
    By directly referring to type of the field.
    We will not be able to create field without a data element
    By using direct type option in SE11 -
    >
    By using Data element option in SE11.
    What is the purpose of SM30?
    SM30 is a table maintanance for the custom tables as well as database tables. -
    >
    None of the options.
    Transaction to create custom table.
    SM30 is a table maintanance for the custom tables created by us.
    What is the difference between selection screen elements and text elements?
    Selection screen elements can only be used for the purpose of display names in selection screen wheareas text elements are reusable and dynamic text definition which can be used across the program. -
    >
    Text elements are static whereas selection screen elements are dynamic
    Both can be used to define a text definition and can be used in the entire program.
    Selection screen elements can only be used for the purpose of display names in selection screen wheareas text elements are reusable and dynamic text definition which can be used across the program other than selection screen.
    Local Variables cab be used in the whole program but not outside the program it is defined.
    True -
    >
    False
    What is the different between clear and refresh?
    Clear is used to clear the work area whereas Refresh to clear the contents of database or internal table.
    Clear is used to clear the header content whereas Refresh is used to clear the contents of internal tables. -
    >
    Both does the same.
    Depending on the internal table declaration, either clear or refresh is used.
    How many indexes can be created for a table?
    9
    1
    As many as required. -
    >
    4
    How to access the logic coded in a program other than the one you are coding in?
    By using SUBMIT command. -
    >
    All of the options are valid.
    By using CALL PROGRAM command.
    By using INCLUDE command
    What is data class?
    The data class specifies in which table space the table is created in database. -
    > not sure
    All of the options.
    The data class specifies what table type is created in database.
    The data class specifies what size table is created in database.
    For concatenating variables, variables must be of type..
    Character or String only.
    Variables of all types can be concatenated.
    Character type only. -
    >
    String only.
    Regards,
    Guna..

  • Difference between bex user exit and macros in functionality?

    Hi all,
    I need to create a report on material master data. I created an infoset on 0material and 0mat_plant. In the requirem
    ent, I have a report containing different material numbers followed by attributes in each row. the final column in each
    row should be calculated using logic. the logic involves comparing different row values and arrive at final conclusion.
    the logic comprises of large number of if conditions. so should i use bex user exit or excel macros?
    what is the difference between user exit and macros in funcitonalilty?
    is there an issue transporting the macro to Prod for end users to use?
    any performance criteria?
    Any how to documents ..will be of a lot of help
    plz send them to [email protected]
    Message was edited by:
            ravi a

    Hi,
    Macros offer a powerful and flexible way to extend the features of MS Excel. You can either create a macro using VB code or Record a macro. Use Alt+F11 for creating macro using VB code.
    You can refer to Microsoft help site or this link for more details:
    http://www.taltech.com/support/sw_tricks/exmacros.htm
    User-exits are empty subroutines that SAP Developers have provided for you.You can fill them with your own source code.Technically this is a modification.Customer exits are nothing but a include in customer name space will be provided in the function module which starts with CALL CUSTOMER.You can fill them with your own source code.Technically this is an enhancement.
    look into following links for procedure to find and use user-exits transaction for finding user-exits is 'SMOD'
    http://www.sapbrain.com/TUTORIALS/TECHNICAL/user_exits_tutorial.html
    http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm

  • There is nothing printed in "Notes" section for the invoice. (Sapscript)

    Dear All,
    The print shows that nothing is printing in the u201CNotesu201D section for the invoice.
    For example, if this was entered by an English user, then they would enter English, but the print may come out in German. In this case, the English notes need to be printed, even though the actual print is in German.
    It should print the notes in whatever language was there & not be limited to the language of the actual print.
    Could someone else guide me to resolve this issue?
    Thanks.

    HI friend,
    Do like this,
    1. Create performs instead of include. This link give you a sample how to create a subroutine in SAP SCript [Calling subroutine from SAP Script|http://forums.sdn.sap.com/thread.jspa?threadID=1774919].
    2. The form of perform could be in your driver program itself.
    3. In the form use the function "READ_TEXT" to read the include text. See the function "READ_TEXT" you can understand it clearly.
    4. You will be getting the text in a internal table. Pass that to the smart forms. You can do that by using subroutines itself.
    5. Like wise do for all.
    I think this will solve your problem if you face any issues revert back to me i will help you.
    Thanks,
    Sri Hari
    Edited by: srihari.kumar on Feb 13, 2012 1:20 PM

  • User exitsq

    waht r types of user_exits?it is my previous inter question.can any one help me

    Hi Pandu,
    Go through the following Document
    User-exits are empty subroutines that SAP have provided to be filled by us. we can fill them with our own source code, they are in the standard sap programs so, technically this is a modification.
    user exit is any place within standard SAP, where SAP have added
    a mechanism for client specific code to be executed.
    USER EXITS are FORMS and are called by SAP standard programs using PERFORM.Inside the form (user exit) you can read and change almost any global data from host program.
    User exits are more flexible because you have more information to use in your codebut on the other hand,it is very easy to manipulate erroneously global data and leadthe standard program to a dump or even to make database inconsistent.
    check...
    user exit / field exit
    User Exits
    Screen exits are exits that allow you to use a reserved part of the screen (A subscreen) to display or input data.
    It is determined be SAP where the sub screen will be displayed.
    The syntax is: CALL CUSTOMER-SUBSCREEN
    The screen exit is not processed untill the corresponding subscreen has been created in an enhancement project,
    and the project has been activated.
    Note:
    Function codes are only processed in the main screens flow logic
    You are not allowed to enter a name for the subscreens command field
    You are not allowed to define GUI stauses
    You are not allowed to enter a value for Next screen
    The global data of the program is not available for the subscreen. Data for the subscreen is provided by function modules.
    These function modules belongs to the same function group as the subscreen Subscreens are edited with transaction CMOD.
    When you activate a project containg subscreens, the calling screen is regenerated and the subscreen is displayed next
    time you display the calling screen
    The developer must create the subscreen and the corresponding PBO and PAI modules
    How to identify screen exits
    Look after CALL CUSTOMER-SUBSCREEN in the screenprogram of the screen you want to modify.
    Use transaction CMOD menu Utillities -> SAP enhancements to search for screen exits
    MENU EXITS
    Menu exits allow you to add your own functionallity to menus. Menu exits are implemented by SAP, and are reserved menu
    entries in the GUI interface. The developer can add his/her own text and logic for the menu.
    Function codes for menu exits all start with "+"
    Example
    We want to create a new menu item in the Office menu. The text for the menu should be "Run ZTEST", and the menu will
    run report ZTEST.
    Goto transaction SE43 Area Menu Maintenance
    In Area Menu Paramenter type 'S000' (S triple Zero)
    Select Change and ignore all the warning screens
    Expand the office menu. In the buttom of the office tree you will find a menu named "Customer function"
    Double click on the text. In the pop-up screen change the text to "Run ZTEST". Note that the trsnaction code is +C01
    Goto transaction SE93 and create transaction +C01 that calls report ZTEST.
    Now you will se the menu displayed in the office tree. If you delete transaction +C01 again, the new menu will dissapear.
    USER EXITS
    User exits (Function module exits) are exits developed by SAP. The exit is implementerd as a call to a functionmodule.
    The code for the function module is writeen by the developer. You are not writing the code directly in the function module,
    but in the include that is implemented in the function module.
    The naming standard of function modules for functionmodule exits is: EXIT_<program name><3 digit suffix>
    The call to a functionmodule exit is implemented as: CALL CUSTOMER.-FUNCTION <3 digit suffix>
    Example:
    The program for transaction VA01 Create salesorder is SAPMV45A
    If you search for CALL CUSTOMER-FUNCTION i program SAPMV45A you will find ( Among other user exits):
    CALL CUSTOMER-FUNCTION '003'
    exporting
    xvbak = vbak
    xvbuk = vbuk
    xkomk = tkomk
    importing
    lvf_subrc = lvf_subrc
    tables
    xvbfa = xvbfa
    xvbap = xvbap
    xvbup = xvbup.
    The exit calls function module EXIT_SAPMV45A_003
    2. How to find user exits
    Display the program where you are searching for and exit and search for CALL CUSTOMER-EXIT
    If you know the Exit name, go to transaction CMOD. Choose menu Utillities->SAP Enhancements.
    Enter the exit name and press enter.
    You will now come to a screen that shows the function module exits for the exit.
    3. Using Project management of SAP Enhancements
    We want to create a project to enahance trasnaction VA01
    Go to transaction CMOD
    Create a project called ZVA01
    Choose the Enhancement assign radio button and press the Change button
    In the first column enter V45A0002 Predefine sold-to party in sales document . Note that an enhancement can only
    be used i 1 project. If the enhancement is allready in use, and error message will be displayed
    Press Save
    Press Components. You can now see that enhancement uses user exit EXIT_SAPMV45A_002. Double click on the exit.
    Now the function module is displayed. Double click on include ZXVVAU04 in the function module
    Insert the following code into the include: E_KUNNR = '2155'.
    Activate the include program. Go back to CMOD and activate the project.
    Goto transaction VA01 and craete a salesorder. Note that Sold-to-party now automatically is "2155"
    Have look at this links
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf
    http://www.sapgenie.com/abap/ole.htm
    http://help.sap.com/saphelp_46c/helpdata/en/59/ae3f2e488f11d189490000e829fbbd/frameset.htm
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf
    In ABAP context , interfaces are only of two types.
    1) INBOUND interfaces
    2)OUTBOUND Interfaces.
    INBOUND:(from external system data is fetched as flat files which is moved to SAP database tables).
    in this process we get data in the form of flat files(.txt or .xlx). we will read this data from the files using FM like UPLOAD/WS_UPLOAD/GUI_UPLOAD into internal
    tables. And using BDC methods or LSMW tool, we will update the database tables with this data.
    OUTBOUND:(Data from SAP dtabase is retrieved adn stored as flatfiles on presentaion server or application server)
    In this process we retrieve data using select statements from the database tables and will populate the internal tables. based on the requirement, we will use FM like DOWNLOAD/WS_DOWNLAOD/GUI_DOWNLOAD to write data from internal tables to flat files on th presentation server.
    *the above mentioned Fm will work for files on presentaion server(local file system) . IF u want to handle files on the application server, use DATASET.
    Other technologies that u mentioned like RFC, BAPI, EDI,ALE, IDOCS etc might be used as apart of interface code.
    Regards
    Sreeni

Maybe you are looking for