cancel
Showing results for 
Search instead for 
Did you mean: 

Calculation of values in a dunning form (SAP Script)

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

sangeetha_sk
Participant
0 Kudos

I think once you get the value from the perform, during printing i.e in form you can do formating in sapscript

Syntax:

&symbol(C)&

Also there are lot of formating commands is there in sap script which we can use while printing

Thanx

Sangeetha

Former Member
0 Kudos

hi,

Use string data type for Z_FAEBT field in PERFORM ZFAEBT IN PROGRAM Z_FI_KX_DUNN_02_INTEREST.

regards,

manjula.m

Former Member
0 Kudos

Dear Manjula!

Thanks for your quick response. For a better understanding of your hint I added the DATA-Definition of the ABAP-code below. Maybe it's easier to comment in the code in order not to missunderstand your hint.

Thanks,

Bernd

REPORT z_fi_kx_dunn_02_interest.

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(255) TYPE c,

z_zinhw(255) TYPE c,

z_mhngh(255) TYPE c,

z_faebt(255) TYPE c.

.....

Edited by: Bernd Thielemann on Jun 16, 2009 1:42 PM

Former Member
0 Kudos

hi,

use this code.

data : Z_FAEBT type string.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

i have not read this complete discussion, I only want to say. The interface between SCRIPT and PERFORM routine is done with variables which are treated as strings (both ways). if you keep that in mind you can figure it out.

So in your perform you are receving strings. If it has to be numbers you have to use/make a conversion routine.

If you have your output and it are numbers you must put it in a string.

Gr., Frank

Former Member
0 Kudos

Hi Frank!

Thanks for your comment. I tried to prepare/modify the received data in the ABAP to numeric rules (by REPLACE-routine) and finally calculation of different amounts was possible. But now the problem is that the value at the end of the ABAP is e.g. 1579.76 whereas in the FORM should be printed as 1.579,76. I'm not familiar with function-builder but now I need a conversion-routine which provides me this printing-format. Must be done in ABAP?

Thanks for support!

Regards,

Bernd

Former Member
0 Kudos

Hi Bernd,

Sorry, but yes you have to translate it.

It is terrible working with performs. Working in the print program is more easy. But with dunning it is a bit tricky because you are working within transaction events.

You need more abap statements to convert it to a decimal number.

Look in the write to field help. There is something with decimals.

success.

Gr., Frank

Former Member
0 Kudos

Hi,

Once check the User Settings.

System->Usser Profile>Own data->Defaults-->Decimal Notation-->Here u can select 2nd one.