Skip to Content
avatar image
Former Member

display value after subtraction on script

I have to display the value calculated as EKPO-NETWR(C) - EKPO-BRTWR(C)

on PO script to represent sales tax of individual item on script.

How can I display value after subtraction?? This cant be done via insert commands as far as i know.

kindly reply,

Thanks.

Regards,

Aisha Ishrat

ICI Pakistan ltd.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jul 17, 2007 at 02:44 AM

    Do it like this.

    IN SAPScript

    /:PERFORM TAX IN PROGRAM Z_TAX

    /:USING &EKPO-NETWR&

    /:USING &EKPO-BRTWR&

    /:CHANGING &DIFFERENCE&

    /:ENDPERFORM

    The report :

    REPORT z_tax .

    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 : NETWR LIKE EKPO-NETWR,

    BRTWR LIKE EKPO-BRTWR,

    DIFF LIKE EKPO-NETWR.

    *----


    *

    • FORM CDE_CENT

    *

    *----


    *

    FORM tax TABLES input output.

    it_input_table[] = input[].

    it_output_table[] = output[].

    READ TABLE it_input_table WITH KEY name = 'EKPO-NETWR'.

    MOVE it_input_table-value TO NETWR.

    READ TABLE it_input_table WITH KEY name = 'EKPO-BRTWR'.

    MOVE it_input_table-value TO BRTWR.

    DIFF = NETWR - BRTWR.

    it_output_table-name = 'DIFFERENCE'.

    MOVE DIFF TO it_output_table-value.

    MODIFY it_output_table INDEX 1.

    ENDFORM.

    Display DIFFERENCE in your SAPscript.

    Reward points.

    Regards,

    SaiRam

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2007 at 01:10 PM

    hi..

    You can perform any calculations in script using perform statement .In subroutine you can perform any calculations reqired and then in export you can get the required values.

    Calling ABAP Subroutines:

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2007 at 03:55 PM

    This can be easily done.

    1) In the driver program, save the substraction value in a variable just before calling the element of the window in which the calculated value will be displayed. And in the SScript output the variable name..

    2) You can also use a PERFORM statement in SScript to do the calculation.

    Hope this helps!.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2007 at 04:07 PM

    Hi

    You have to write a Subroutine in the Script with PERFORM statement and to do the calculation in the program and to pass the value back to script

    see the sample code for writing the subroutine.

    How to call a subroutine form SAPscripts

    The Form :

    /:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK

    /:USING &EKKO-EBELN&

    /:CHANGING &CDECENT&

    /:ENDPERFORM

    The report :

    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.

    Reward points for useful Answers

    Regards

    Anji

    Add comment
    10|10000 characters needed characters exceeded