cancel
Showing results for 
Search instead for 
Did you mean: 

How to Add two fields from the print program in a Sap Script

0 Kudos

Hi,

I want to add two fields(DMBTR and MWSTS) which are Currency values from the BSIK table and display the answer in a Sap Script form and I have to do this addition on the SAP script itself.

Any Input will be highly appreciated.

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

former_member196280
Active Contributor
0 Kudos

Hi wesleymabunda,

You can build a small logic as stated in the below example.

Inside you SAP script call a routine. before you display "MWSTS"

Example:

/: PERFORM GET_TOTAL IN PROGRAM ZROUTINE

/: USING &BSIK-DMBTR&

/: USING &BSIK-MWSTS&

/: CHANGING &TOTAL&

/: ENDPERFORM

Now goto transaction code SE38

And create a new program as ZROUTINE. Logic inside the program should be as stated in the example.

Example:

FORM GET_TOTAL TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy.

DATA: LV_DMBTR LIKE BSIK-DMBTR,

lv_MWSTS LIKE BSIK-MWSTS,

lv_total LIKE regup-zbukr.

CLEAR: lv_dmbtr,

lv_MWSTS,

lv_total.

READ TABLE in_tab INDEX 1.

lv_dmbtr = in_tab-value.

READ TABLE in_tab INDEX 2.

lv_mwsts = in_tab-value.

lv_total = lv_dmbtr + lv_mwsts.

IF NOT lv_total IS INITIAL.

READ TABLE out_tab INDEX 1.

out_tab-value = lv_total.

MODIFY out_tab INDEX 1.

ENDIF.

ENDFORM.

Now go back to SE71, inside your SAp script display &TOTAL& on the location you want to display it. Change the above logic a bit, if you need grand total.

I guess, above information, will help you to close the thread.

Regards,

SaiRam

Answers (1)

Answers (1)

Former Member
0 Kudos

If you already have BSIK-DMBTR , then just put &BSIK-DMBTR& in your SAPScript form where you want it to be printed.

0 Kudos

I am displaying the information like this:

Amount: &bsik-dmbtr&

Tax Amount: &bsik-mwsts&

Total Amount: "for this to be displayed, I have to add both &bsik-dmbtr& and &bsik-mwsts& on the Sap Script, that is where my problem is"

Former Member
0 Kudos

Hi,

You r enhancing standard script or custom script.

If u add any code to standard script using subroutine pool and using PERFORM statement.

STEP1:First where u want to display the two fields in that FIRST WE NEED TO CREATE /E ELEMENT.

STEP2:Pass the two fields data into that script through DRIVER PROGRAM.

STEP3:Create one more /E ELEMENT1 FOR TOTAL.

STEP4:That data calucaltae in driver program pass the total into RESPECTIVE SCRIPT.

CALL FUNCTION WRITE "Two fields values.

ELEMENT = ELE1.

CALL FUNCTION WRITE "TOTAL

ELEMENT = ELE2.

*********THIS PERFORM CALL IN SCRIPT IF U ENHANCE THE STANDARD PROGRAM****

PERFORM FORNAM IN PROGRAM (ZDRIVERPPG) USING "INPUPARAMETERS) CHANGING OUTPUTPAR

*************FORM CALL IN DRIVER PG**************************************

FORM FORMNAME TABLES IT_TAB1 STRUCTURE ITCSY

ITA_TAB2 STRUCTURE ITCSY.

ENDFORM.

REGARDS,

MURALII

0 Kudos

Hi Muralii

I cannot modify the print program because it is a Standard Sap Print Program, I have to do modifications and additions on the Sap Script, I just tried creating an element like this:

/E Answer = &WA_ITAB-ITEMPRICE& + &WA_ITAB-ITEMPRICE&

Total Amount = Answer,

but I got an internal error.

Former Member
0 Kudos

Hi,

You can not modify the print program you must copy the standard form to custom form using

STEP:GOTOSE71-UTILITES-COPYFROMCLIENT.

STEP2:COPY THE STANDARD FORM TO CUSTOM FORM.

STEP3:NOW U CAN WRITE YOU CODE IN CUSTOM FORM.

STEP4:CONFIGURE THAT FORM IN NACE.

REGARDS,

MURALII