Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

script currency declaration

Former Member
0 Likes
1,988

I fetched currency field in my subroutine using select query. How to declare the variable for storing that currency field in subroutine. I declared it as type C its displaying in script but without any decimals. If i declare variable as currency field of some table field refrence data is captured in the variable but it is not displaying in script. How to declare the variable.

19 REPLIES 19
Read only

Former Member
0 Likes
1,860

Within subroutine ,

Declare one varaible as cuurency field ,

move the charcter field value to currency field and do the calculation ,then pass currency value to charcter field.

in layout if you want to display decimals use

&FIELD(.3)& it display 3 decimals..

you have to use offset command in routine.

Reward Points if it is helpful

Thanks

Seshu

Read only

0 Likes
1,860

hi sheshu,

I declared variable as currency field which is displayed in the script. the variable is filled with data but its not displaying in script.

I didn't try &FIELD(.3)&

but i had a doubt if the variable contains any decimals values then how its going to be output

Read only

0 Likes
1,860

hi shehu

i tried but did not get using &variable(.3)&

is there any other way to get plz help

Read only

0 Likes
1,860

see the syntax -

&EKPO-MENGE& -> 1,234.560

&EKPO-MENGE(.1) -> 1,234.6

&EKPO-MENGE&(.4) -> 1,234.5600

&EKPO-MENGE&(.0) -> 1,235

&variable(.3)& use fieldname is in uppercase

Read only

Former Member
0 Likes
1,860

Hi

You either declare it as TYPE P decimals 2

or declare

v_field TYPE NETWR.

in the script You can write using &V_FIELD&

it will write. do and check as above

Reward points for useful Answers

Regards

Anji

Read only

0 Likes
1,860

I tried but no data is output in script

Read only

0 Likes
1,860

Hi

can you paste your code here

what exactly you are doing?

both in program and script how you are writing the field.

so that it is easy for us to give the solution.

Reward points for useful Answers

Regards

Anji

Read only

0 Likes
1,860

In subrotine

data : v_amt type c.

select * from with_item where belnr = reguh-belnr

and bukrs = reguh-bukrs

and gjahr = reguh-gjahr.

if sy-subrc = 0.

v_amt = v_amt + with_item-wt_qbshh.

endif.

endselect.

move v_amt to outab-value.

In script

&v_amt&

Read only

0 Likes
1,860

data : v_amt type c.

<b>data v_amt1 type currency field.</b>

select * from with_item where belnr = reguh-belnr

and bukrs = reguh-bukrs

and gjahr = reguh-gjahr.

if sy-subrc = 0.

v_amt1 = v_amt1 + with_item-wt_qbshh.

endif.

endselect.

<b>move v_amt1 to v_amt.</b>

move v_amt to outab-value.

see the bold one and when you want to display number of decimals then use

&V_AMT(.3)& - 3 DECIMALS

Read only

0 Likes
1,860

sorry right now i am not having system to check.

I had a doubt

if there is a decimal value for suppose in

v_amt value 111.23

and if i copy it to v_amt1

and display in script as u said

&v_amt(.3)&

then whats going to be my output

Read only

0 Likes
1,860

it displays like <b>111.230</b>

Read only

0 Likes
1,860

when i am declaring

data : v_amt1 as regud-swnes. " this field is currency field

and i am pasing the value data is displayed in subroutine but not in script.

or

u mean

data v_amt1 type curr.

Read only

0 Likes
1,860

Hi

In the routine declare two variables

one for CURR field and other one is CHAR type with 16 length

do calculation with CURR field after select

finally when you wants to move the field to script move this CURR field value to CHAR field and pass to OUT_PAR table

this will work

Reward points for useful Answers

Regards

Anji

Read only

0 Likes
1,860

I declared directly as type c

its displaying in script but without decimals.

I need decimal places.

Read only

0 Likes
1,860

charcter field keeps the currency field value as it is,if you get formatting issue in layout level then use (.3) option .

try to test it and let me know.

Read only

0 Likes
1,860

one more problem is there any function module to write this amount in words

in indian currency i searched in se37 i found many but its not showing in lakhs .

Read only

Clemenss
Active Contributor
0 Likes
1,860

Hi hearts g,

find (or define) a DDIC structure with type CURR field for the value with DDIC reference to currency key field of type CUKY.

Fill in value in value field, currency in currency key field.

Use currency field of structure in script.

Regards,

Clemens

Read only

Former Member
0 Likes
1,860

but how to make refrence currency field.

how to declare variable.

Read only

Former Member
0 Likes
1,860

Hi

see the sample code for subroutine

and do accordingly

REPORT ZMPO1 .

form get_freight tables in_par structure itcsy out_par structure itcsy.

tables: ekko,konv,t685t.

data: begin of itab occurs 0,

ebeln like ekko-ebeln,

knumv like ekko-knumv,

end of itab.

data: begin of itab1 occurs 0,

knumv like konv-knumv,

kposn like konv-kposn,

kschl like konv-kschl,

kbetr like konv-kbetr,

waers like konv-waers,

kwert like konv-kwert,

end of itab1.

data: begin of iout occurs 0,

kschl like konv-kschl,

vtext like t685t-vtext,

kbetr like konv-kbetr,

kwert like konv-kwert,

end of iout.

data v_po like ekko-ebeln.

read table in_par with key 'EKKO-EBELN'.

if sy-subrc = 0.

v_po = in_par-value.

select

ebeln

knumv

from ekko

into table itab

where ebeln = v_po.

if sy-subrc = 0.

loop at itab.

select

knumv

kposn

kschl

kbetr

waers

kwert

into table itab1

from konv

where knumv = itab-knumv and

kappl = 'M'.

endloop.

loop at itab1.

if itab1-kposn <> 0.

select single * from t685t

where kschl = itab1-kschl

and kappl = 'M'

and spras = 'EN'.

iout-vtext = t685t-vtext.

iout-kschl = itab1-kschl.

iout-kbetr = itab1-kbetr.

iout-kwert = itab1-kwert.

append iout.

clear iout.

endif.

endloop.

sort itab1 by kposn.

loop at iout.

sort iout by kschl.

if ( iout-kschl eq 'GSDC' OR

iout-kschl eq 'GSFR' OR

iout-kschl eq 'GSIR' ).

at end of kschl.

read table iout index sy-tabix.

sum.

  • write:/ iout-kschl,iout-vtext,iout-kwert.

out_par-name = 'A1'.

out_par-value = iout-vtext.

append out_par.

out_par-name = 'A2'.

out_par-value = iout-kwert.

append out_par.

endat.

endif.

endloop.

endif.

endif.

endform.

  • IN THE FORM I AM WRITING THIS CODE.

/:DEFINE &A1& = ' '

/:DEFINE &A2& = ' '

/:PERFORM GET_FREIGHT IN PROGRAM ZMFORM_PO1

/:USING &EKKO-EBELN&

/:CHANGING &A1&

/:CHANGING &A2&

/:ENDPERFORM

  • &A1&

  • &A2&

This Code is to be written in the PO form under ADDRESS window.

-


/:DEFINE &A1& = ' '

/:DEFINE &A2& = ' '

/:DEFINE &A3& = ' '

/:DEFINE &A4& = ' '

/:DEFINE &A5& = ' '

/:DEFINE &A6& = ' '

/:PERFORM GET_VENDOR IN PROGRAM ZMFORM_PO

/:USING &EKKO-EBELN&

/:CHANGING &A1&

/:CHANGING &A2&

/:CHANGING &A3&

/:CHANGING &A4&

/:CHANGING &A5&

/:CHANGING &A6&

/:ENDPERFORM

  • &A1&

  • &A2&

  • &A3&

  • &A4&

  • &A5&

  • &A6&

Reward points for useful Answers

Regards

Anji