Sap script subroutine

my requirement:
I want to divide the DMBTR field (currency) by MENGE field (quantity).I gave the perform endperform in script. Now i am coding the subroutine . this is what i've coded.
form f_division
TABLES INTAB STRUCTURE ITCSY
OUTTAB STRUCTURE ITCSY .
DATA : V1 TYPE BSEG-DMBTR,
       V2 TYPE BSEG-MENGE,
       V3(13) TYPE C,
       RESULT TYPE P DECIMALS 2.
Read Table INTAB INDEX 1.
V1 = INTAB-VALUE.
Replace "," with "." into v3.
v1  =  v3.
Read Table INTAB INDEX 2.
V2 = INTAB-VALUE.
Replace "," with "." into v3.
v2 = v3.
IF V2 NE 0 OR NOT V2 IS INITIAL. "for Division by 0
RESULT = V1 / V2.
ENDIF.
WRITE RESULT TO OUTTAB-VALUE LEFT-JUSTIFIED.
MODIFY OUTTAB TRANSPORTING VALUE WHERE NAME = 'TMP'.
endform.
Here i've assigned V1 to dmbtr and V2 to menge. The v3(13)  is a temporary variable i introduced so that the format of dmtbr is <b>12,98</b> is changed to <u><b><u>12.98</u></b></u> .ie. the comma is changed to a point(fullstop). Now that i coded this i get an error stating "IN EXPECTED AFTER V1". plz temme how do i go abt this.

hI ALL,
IF USE THE FOLLWING CODE IT WORKS.
TABLES intab STRUCTURE itcsy
outtab STRUCTURE itcsy .
DATA : v1 LIKE bseg-dmbtr,
       v2 LIKE bseg-menge,
       TEMP1(255) TYPE C,
       TEMP2(255) TYPE C,
       result TYPE p DECIMALS 2.
READ TABLE intab INDEX 1.
TEMP1 = intab-value+242(13).
v1 =  TEMP1.
READ TABLE intab INDEX 2.
TEMP2 = intab-value+242(13).
v2 = temp2.
IF v2 NE 0 OR NOT v2 IS INITIAL. "for Division by 0
result = v1 / v2.
ENDIF.
WRITE result TO outtab-value LEFT-JUSTIFIED.
MODIFY outtab TRANSPORTING value WHERE name = 'TMP'.
ENDFORM.                    " f_division

Similar Messages

  • 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

  • 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

  • Subroutine call from SAP Script

    Hi,
    I need to calculate required/outstanding qty. hence am passing existing values of reservation#/item# and issued qty.
    both req/out qty are returned blank by the code. please help.
    Following is my code segment for a external routine call from SAP Script.
    /:   PERFORM P_GET_QTY IN PROGRAM ZTEST
    /:   USING &MSEG-RSNUM&                     
    /:   USING &MSEG-RSPOS&                     
    /:   CHANGING &REQ_QTY&                     
    /:   CHANGING &MSEG-MENGE&                  
    /:   CHANGING &OUT_QTY&                     
    /:   ENDPERFORM
    REPORT ztest .
    TABLES resb.
    DATA: wa_resb TYPE resb,
          req_qty TYPE resb-bdmng,
          isd_qty TYPE mseg-menge,
          out_qty TYPE resb-bdmng.
    FORM p_get_qty TABLES input  STRUCTURE itcsy
                          output STRUCTURE itcsy.
      DATA: avlbl TYPE resb-bdmng.
      READ TABLE input WITH KEY 'MSEG-RSNUM'.
      CHECK sy-subrc = 0.
      wa_resb-rsnum = input-value.
      READ TABLE input WITH KEY 'MSEG-RSPOS'.
      CHECK sy-subrc = 0.
      wa_resb-rspos = input-value.
      READ TABLE input WITH KEY 'REQ_QTY'.
      CHECK sy-subrc = 0.
      req_qty = input-value.
      READ TABLE input WITH KEY 'MSEG-MENGE'.
      CHECK sy-subrc = 0.
      isd_qty = input-value.
      SELECT SINGLE * INTO wa_resb
                      FROM resb
                      WHERE rsnum = wa_resb-rsnum
                      AND   rspos = wa_resb-rspos.
      CHECK sy-subrc = 0.
      avlbl   = wa_resb-bdmng - wa_resb-enmng.
      req_qty = avlbl - out_qty.
      out_qty = req_qty - isd_qty.
      output-name = 'REQ_QTY'.
      output-value = req_qty.
    MODIFY output TRANSPORTING name value WHERE name = 'REQ_QTY'.
      APPEND output.
      output-name = 'OUT_QTY'.
      output-value = out_qty.
    MODIFY output TRANSPORTING name value WHERE name = 'OUT_QTY'.
      APPEND output.
    ENDFORM.
    Thanks,
    Ram.

    Hi Ram,
    I think you have to use MODIFY instead of append for the OUTPUT table.
    MOdify the table with KEY. This should resolve the problem.
    Ram, you can check this code and see how the MODIFY is to be used.
    REPORT YLSD999A.
    DATA  W_LENGTH TYPE I.
    *   GENERAL PURPOSE SUBROUTINES FOR CALLING FROM SAPSCRIPTS
    FORM DISPLAY_POUND TABLES IN_TAB STRUCTURE ITCSY
                              OUT_TAB STRUCTURE ITCSY.
      DATA: COUNT TYPE P VALUE 16.
      DATA: W_VALUE(17) TYPE C.        "defined as 7 chars to remove pence
      DATA: W_CHAR TYPE C.
      DATA: W_DUMMY TYPE C.
      DATA: W_CURR(3) TYPE C.
    *    Get first  parameter in input table.
      READ TABLE IN_TAB INDEX 1.
      WRITE IN_TAB-VALUE TO W_VALUE .
    * get second parameter in input table
      READ TABLE IN_TAB INDEX 2.
      MOVE IN_TAB-VALUE TO W_CURR.
      IF W_CURR = 'GBP'.
        W_CURR = '£'.
      ENDIF.
      W_LENGTH = STRLEN( W_CURR ).
    *    look for first space starting at right.
      WHILE COUNT > -1.
        W_CHAR = W_VALUE+COUNT(1).
    *  W_CHAR = IN_TAB-VALUE+COUNT(1).
        IF W_CHAR = ' '.
          COUNT = COUNT - W_LENGTH + 1.
          W_VALUE+COUNT(W_LENGTH) = W_CURR.
          COUNT = -1.
        ELSE.
    *     W_VALUE+COUNT(1) = W_CHAR.
          COUNT = COUNT - 1.
        ENDIF.
      ENDWHILE.
    * read only parameter in output table
      READ TABLE OUT_TAB INDEX 1.
      OUT_TAB-VALUE = W_VALUE.
      MODIFY OUT_TAB INDEX SY-TABIX.
    ENDFORM.
    Cheers
    VJ

  • 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

  • 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.

  • 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

  • Missing fields in the output while using SAP SCRIPT

    Hi,
    I am working on an issue where we are using F110 to print some checks, and for this we have created a custom sap script and we are using a std driver program RFFOUS_C, we have also maintianed a custom subroutine pool ZRFFOUS which will retrieve the missing data for the sap script which was not there in the std. program. Now we have applied a SP to our system and since then we are having a problem...when we are printing the chechks its missing some fields.
    Surpisingly, it is happening for all scripts like Dunning, invoice......
    These scripts are working good in production which is not applied patches.
    I have tried in all ways, did debug, data is there in tables and scripts are exactly same as in production.
    Could you please share any ideas regarding this? What would be the effect of patches?
    Thanks
    Sha

    Hi ,
    I think u r printing the Check through the Tr Code F110.
    In that program u r using the Standard Driver Program RFFOUS_C and u create a New Sap script.
    and also u also mantained the custom subroutine pool ZRFFOUS .  when ru giving printing u are  not able to print some  field.
    In this case  when u using the Standard driver Program RFFOUS_C in that program there is a Include Progran  * RFFORI01---- check  , 
    in this program it is calling the Standard Form (F110PRENUM_CHCK) i--e t042e-zforn .as shown in the below and it is calling the function module 'OPEN_FORM'._
    Please copy  the form  asZF110_PRENUM_CHCK and  and do the changes in that form . and we need to maintained the Form as Company code level  -- and it will shown this Table T042E (Company Code-Specific Specifications for Payment Methods)
    Please go to Transaction Code FBZP  and U can maitained the  New Sap Script Form Company Code Level.
    one thing while u calling your new subroutine pool ZRFFOUS  Please call  this subroutine in  your Sap Script form then only u can see all values in your Check.  and Actvate the Sap script .
    Like U can call your new  subroutine ZRFFOUS  in your New Sap script Program.
    /E   CHECK
    /:   PERFORM XXXXXXX IN PROGRAM XXXXXX''                  
    /:   PERFORM CHECK_NAME IN PROGRAM  ZRFFOUS
    /:   USING &XXXXXXX&                      
    /:   CHANGING &XXXXXX&                   
    /:   ENDPERFORM                              
    In the subroutine pool ZRFFOUS   u have to call  as
    FORM CHECK_NAME TABLES t_data_in  STRUCTURE itcsy
                                                   t_data_out STRUCTURE itcsy.
    xxxxx
    xxxxx
    xxxxx
    ENDFORM.
    In this case  when u using the Standard driver Program RFFOUS_C in that program there is a Include Progran  * RFFORI01---- check  , 
    in this program it is calling the Standard Form (F110_PRENUM_CHCK) i--e t042e-zforn .
        open check form
          CALL FUNCTION 'OPEN_FORM'
               EXPORTING
                    form     =  t042e-zforn
                    device   = 'PRINTER'
                    language = t001-spras
                    options  = itcpo
                    dialog   = space
               EXCEPTIONS
                    form     = 1.
          IF sy-subrc EQ 1.                "abend:
            IF sy-batch EQ space.          "form is not active
              MESSAGE a069 WITH t042e-zforn.
            ELSE.
              MESSAGE s069 WITH t042e-zforn.
              MESSAGE s094.
              STOP.
            ENDIF.
          ENDIF.
    I thing it will help u to solve this issue.
    Thanks.
    Gagan

  • Unable to print multiple line items in Z-SAP SCRIPT

    Hi ALL,
    We have a scenario where in we are calling the Driver program (RFKORD50) for Document Extract(F.64), Where in we have attached the Z-Script to the program(RFKORD50),
    Unable to print multiple items.
    1) Checked with all the elements in STD program for printing multiple items in main window but unable to get all the items we are able to fetch only 1 item .
    (&BSEG-BUZEI&,,     &BSEG-SGTXT&,,,,&BSEG-DMBTR&)
    2) I have also tried with external subroutine but it also didnot work.it is fetching the latest value.
    Ex: if we have 3 items say 1,2,3 first 2 items are not getting fetched it is taking 3rd item and printing it straight away(Problem is it is not going to script for fetching the first item).
    see the perform which i have used
    /: PERFORM ITEMS IN PROGRAM ZTFI_ZNV20296
    /:USING &BSEG-BUKRS&
    /:USING &BKPF-BELNR&
    /:USING &BSEG-GJAHR&
    /:CHANGING &V_BUZEI&
    /:CHANGING &V_SGTXT&
    /:CHANGING &V_DMBTR&
    /: ENDPERFORM
    IL  &V_BUZEI&,,     &V_SGTXT&,,,,&V_DMBTR&
    Please suggest me whetther we can call write_form from external subroutine. or is there any loop commands in SAP SCRIPT Form.
    Regards,
    Jana

    Hi!
    The LOOP is always within the printer program. In this case also.
    Just check out the RFKORI35 include, the LOOP begins in the 215th line (in 4.6C).
    SORT HBSEG BY BUKRS SORTP1 SORTP2 SORTP3 SORTP4 SORTP5
                          BELNR GJAHR BUZEI.
            LOOP AT HBSEG.
    *         WHERE BUKRS = SAVE_BUKRS.
              SAVE_BUKRS  = HBSEG-BUKRS.
              IF  ( HBSEG-KUNNR = SAVE_KUNNR
              AND   NOT SAVE_KUNNR IS INITIAL )
              OR  ( HBSEG-LIFNR = SAVE_LIFNR
              AND   NOT SAVE_LIFNR IS INITIAL ).
                CLEAR RF140-ELEMENT.
                RF140-ELEMENT = '521'.
                CALL FUNCTION 'WRITE_FORM'
                         EXPORTING  WINDOW    = 'MAIN'
                                    ELEMENT   = '521'
                         EXCEPTIONS WINDOW    = 1
                                    ELEMENT   = 2.
    You might try out to write your code within the 521 elemnt in the sapscript.
    Regards
    Tamás
    Edited by: Tamás Nyisztor on Jun 12, 2008 3:34 PM

  • SAP SCRIPT Header text and Item text not printing in customized PO

    Hello Experts,
                          I have copied the standard MEDRUCK to ZMEDRUCK and customized the form according to the requirement.
    I want to print the header text and Item text in my form.
    For Header text I have used :
    /: INCLUDE &EKKO-EBELN& OBJECT EKKO ID F01
    Problem 1: The text what I enter in header text is flowing only when I hit on print preview without saving the form. Once I save the SAP SCRIPT  and click on print preview the field is appearing blank. I also tried to print the form, but the field is appearing blank even on the print out.
    Problem 2: For item text the field is concatenation of  EBELN & EBELP. Can anyone suggest me how to concatenate and fetch the text in item text.

    Hi,
        Im getting an error in my subroutine pool for i_xtline which is to fetch ITEM TEXT., It says its not a in any internal table nor defined as data. How can I proceed further. I have pasted my code below. Please check and revert ASAP
    PROGRAM  ZMEDRUCK_SUBP1.
    TABLES: EKPO, EKKO.
    FORM fetch_table_data TABLES in_tab STRUCTURE itcsy
                                 out_tab STRUCTURE itcsy.
    data xname like THEAD-TDNAME.
    data i_xtline like xtline.
    clear i_xtline.
    refresh i_xtline.
    CONCATENATE EKPO-ebeln EKPO-ebelp INTO v_item_text.
    MOVE v_item_text to ITEMTXT.
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
      CLIENT                        = SY-MANDT
        id                            = F01
        language                      = EN
        name                          = ITEMTXT
        object                        = EKPO
      ARCHIVE_HANDLE                = 0
      LOCAL_CAT                     = ' '
    IMPORTING
      HEADER                        =
      tables
        lines                         = i_xtline
    EXCEPTIONS
       ID                            = 1
       LANGUAGE                      = 2
       NAME                          = 3
       NOT_FOUND                     = 4
       OBJECT                        = 5
       REFERENCE_CHECK               = 6
      WRONG_ACCESS_TO_ARCHIVE       = 7
      OTHERS                        = 8
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.

  • Calculation of values in a dunning form (SAP Script)

    Hi Experts!
    I want to add values to a sum (dunning-amount + dunning-fee + interest) in a dunning form (SAP Script; Z150_DUNN_02).Therefore I'm using a subroutine (Z_FI_KX_DUNN_02_INTEREST) to summarize. Problem is the format of the output-field &Z_FAEBT&. It's not similar to field &MHNK-FAEBT& which was formerly printed (without calculation of interest and dunning-fees.
    /:   DEFINE &Z_FAEHW& := &MHNK-FAEHW&                 
    /:   DEFINE &Z_ZINHW& := &MHNK-ZINHW&                 
    /:   DEFINE &Z_MHNGH& := &MHNK-MHNGH&                 
    /:   DEFINE &Z_FAEBT& := &MHNK-FAEBT&                 
    /:   PERFORM ZFAEBT IN PROGRAM Z_FI_KX_DUNN_02_INTEREST
    /:   USING &Z_FAEHW&                                  
    /:   USING &Z_ZINHW&                                  
    /:   USING &Z_MHNGH&                                  
    /:   CHANGING &Z_FAEBT&                               
    /:   ENDPERFORM                                       
    /:   ENDIF                                            
    A3   &MHNK-WAERS& &Z_FAEBT(C)&       
    It would be fine to get a hint how to format the field &Z_FAEBT& correctly. Must be done in the subroutine Z_FI_KX_DUNN_02_INTEREST by a special WRITE-command? Is it possible to add these values only in the form?
    Thanks for support!
    Regards, Bernd

    hi!
    I defined the field like you said! After moving this field to a numeric field to add the different amounts the
    following error occurred:
    Runtime errors         CONVT_NO_NUMBER           
    Exception              CX_SY_CONVERSION_NO_NUMBER
    Occurred on     16.06.2009 at   15:15:25  
    Unable to interpret " 1.316,59" as a number.     
    Definition:
    FORM zfaebt TABLES in_par STRUCTURE itcsy
                       out_par STRUCTURE itcsy.
      TABLES: mhnk.
      DATA: z_faehw_num LIKE mhnk-faehw,
            z_zinhw_num LIKE mhnk-zinhw,
            z_mhngh_num LIKE mhnk-mhngh,
            z_faebt_num LIKE mhnk-faebt.
      DATA: z_faehw TYPE string,
            z_zinhw TYPE string,
            z_mhngh TYPE string,
            z_faebt TYPE string.
    statement:
      READ TABLE in_par WITH KEY 'Z_FAEHW'.
      CHECK sy-subrc = 0.
      z_faehw = in_par-value.
      z_faehw_num = z_faehw.
    I suppose a type-conflict.
    Regard, Bernd

  • How to print the Totals in SAP Scripts..?

    Hi,
    I have an SAP Script layout. Currently I am displaying the Line items in the layout. The new requirement has come up to display the TOTAL of the amount value in the layout at the end of the line items. Can someone tell me how to display the Sum of the Amount value at the end of the Line items in an SAP Script.
    The Print program for this layout is standard program. Can this be handled within the layout..? Someone please provide me some sample code if available.
    Thanks in advance.
    Best regards,
    Paddu.

    Hi,
    Thank you for your reply.
    My Standard print program doesn't provide the total value.  Could you please tell me where exactly we need to write the logic in the Layout. I mean, do we need to write under separate element..? and in the External subroutine, how would be the logic. It would be greatful if you provide some sample code.
    Thanks & Regards,
    Paddu.

  • How to use perform statements in sap scripts

    how to use perform statements in sap scripts . and pls send me one progam for this
    thnaks
    raja

    Hi Raja,
    <b>PERFORM</b> key work is used to include subroutine in sapscript form...
    But the processing is lttle bit different form the one we use in ABAP.
    Here the paramters passed to form is stored in internal table of name-value table. there are two table one for inbound parameter and other for outbound parameters.
    Check out the example below to see how this is used..
    <b>Definition in the SAPscript form:</b>
    /: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
    /: USING &PAGE&
    /: USING &NEXTPAGE&
    /: CHANGING &BARCODE&
    /: ENDPERFORM
    / &BARCODE&
    <b>Coding of the calling ABAP program:</b>
    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.
    Hope this is clear to understand...
    Enjoy SAP.
    Pankaj Singh.

Maybe you are looking for