on 07-16-2007 1:52 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have done this as:
on script, i wrote :
Sales Tax for individual item**************
DEFINE &PRICE_WITH_TAX& = &EKPO-NETWR&
DEFINE &PRICE_WITHOUT_TAX& = &EKPO-BRTWR&
DEFINE &DIFFERENCE& = ' '
PERFORM GET_SALES_TAX IN PROGRAM ZMYSPELL
USING &PRICE_WITH_TAX&
USING &PRICE_WITHOUT_TAX&
CHANGING &DIFFERENCE&
ENDPERFORM
and for value display , i wrote :
&DIFFERENCE(.2)&
On program, i wrote :
*----
*
FORM GET_SALES_TAX
*
*----
*
FORM GET_SALES_TAX TABLES input output.
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 TYPE P DECIMALS 2,
BRTWR TYPE P DECIMALS 2,
DIFF TYPE P DECIMALS 2,
TEST(20).
BREAK-POINT.
it_input_table[] = input[].
it_output_table[] = output[].
READ TABLE it_input_table WITH KEY name = 'PRICE_WITH_TAX'.
MOVE it_input_table-value TO TEST.
TRANSLATE TEST USING ', '.
CONDENSE TEST NO-GAPS.
MOVE TEST TO NETWR.
READ TABLE it_input_table WITH KEY name = 'PRICE_WITHOUT_TAX'.
MOVE it_input_table-value TO TEST.
TRANSLATE TEST USING ', '.
CONDENSE TEST NO-GAPS.
MOVE TEST TO BRTWR.
DIFF = NETWR - BRTWR.
MOVE DIFF TO TEST.
it_output_table-name = 'DIFFERENCE'.
MOVE TEST TO it_output_table-value.
MODIFY it_output_table INDEX 1.
ENDFORM.
The problem is that it does not display any value on script,i have debugged the program, it throws correct value to the ouput table but no display on script.
any solution??
Regards,
Aisha Ishrat,
ICI Pakistan Ltd.
Try this
<b>MODIFY it_output_table WITH KEY name = 'DIFFERENCE'.</b>
Shuld work... if not,
Set breakpoint at "MODIFY it_output_table INDEX 1." in subroutine and see the contents it_output_table whether the difference is placed in <internal table or not>.
Note:
In SAPSCRIPT use following notation for calling subroutine
<b>/:</b> PERFORM GET_SALES_TAX IN PROGRAM ZMYSPELL
<b>/:</b> USING &PRICE_WITH_TAX&
<b>/:</b> USING &PRICE_WITHOUT_TAX&
<b>/:</b> CHANGING &DIFFERENCE&
<b>/:</b> ENDPERFORM
Reward points to all useful answers.
Regards,
SaiRam
COPY and paste the below code ... It will work I made required modifications to it.
If still not working set break-point in SAPSCRIPT and tell me the value of DIFFENENCE in SAPSCRIPT.
/: PERFORM GET_SALES_TAX IN PROGRAM ZMYSPELL
/: USING &PRICE_WITH_TAX&
/: USING &PRICE_WITHOUT_TAX&
/: CHANGING &DIFFERENCE&
/: ENDPERFORM
RESULT = &DIFFERENCE(.2)&
*************************************************
SUBROUTINE DEFINITION IN THE PROGRAM: ZMYSPELL
<b>FORM GET_SALES_TAX TABLES INTAB STRUCTURE ITCSY
OUTTAB STRUCTURE ITCSY.
DATA : NETWR TYPE P DECIMALS 2,
BRTWR TYPE P DECIMALS 2,
DIFF TYPE P DECIMALS 2.
DATA : TEXT(20).
read table INTAB WITH KEY name = 'PRICE_WITH_TAX'.
TEST = INTAB-VALUE.
TRANSLATE TEST USING ', '.
CONDENSE TEST NO-GAPS.
MOVE TEST TO NETWR.
CLEAR : text.
read table INTAB WITH KEY name = 'PRICE_WITHOUT_TAX'.
TEST = INTAB-VALUE.
TRANSLATE TEST USING ', '.
CONDENSE TEST NO-GAPS.
MOVE TEST TO BRTWR.
DIFF = NETWR - BRTWR.
MOVE DIFF TO TEST.
read table OUTTAB with key NAME = 'DIFFERENCE'.
if sy-subrc = 0.
OUTTAB-VALUE = TEST.
modify OUTTAB index SY-TABIX .
endif.
ENDFORM.</b>
Regards,
SaiRam
I have done this as :
----
FORM GET_SALES_TAX
*
----
FORM GET_SALES_TAX TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
DATA: TEST(20),
TOTALSUM(20),
TOTAL(20) TYPE N ,
TOTAL1(20) TYPE N ,
SUM(20),
TESTN(16) TYPE P DECIMALS 4,
SUMN(16) TYPE P DECIMALS 4,
TESTC TYPE I,
SUMVARC(20),
SUMC(20),
AMT6 TYPE P DECIMALS 0,
CURVAR LIKE SY-WAERS.
bREAK-POINT.
READ TABLE IN_TAB WITH KEY 'PRICE_WITH_TAX'.
MOVE IN_TAB-VALUE TO TEST.
TRANSLATE TEST USING ', '.
CONDENSE TEST NO-GAPS.
MOVE TEST TO TESTN.
READ TABLE IN_TAB WITH KEY 'PRICE_WITHOUT_TAX'.
SUM = IN_TAB-VALUE.
TRANSLATE SUM USING ', '.
CONDENSE SUM NO-GAPS.
MOVE SUM TO SUMN.
*WRITE: SUM TO SUMN.
TESTN = TESTN - SUMN.
*MOVE TESTN TO TESTC.
*CONDENSE TOTALSUM.
MOVE TESTN TO TOTALSUM.
*WRITE AMT6 TO TOTALSUM.
*WRITE TESTN TO TOTALSUM NO-ZERO.
READ TABLE OUT_TAB WITH KEY 'DIFFERENCE'.
*WRITE TESTN TO OUT_TAB-VALUE .
OUT_TAB-VALUE = TOTALSUM.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDFORM.
Its working,
Many Thanks.
Regards,
Aisha Ishrat
ICI Pakistan Ltd.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.