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

Data Format

Former Member
0 Likes
1,303

Hi Friends,

I am sending data to an external system through an internal table(i_input). However the external system can read data only in CHAR format.

For my quantity field when i use quantity as (eg - line item 1 quantity is 3.500 T and for line item 2 quantity field is 1.000 T and when i add line 1 and 2 and modify my internal table the quantity is shown as 4500 T)

i_input like ZSDINPUT occurs 0 with header line.

ZSDINPUT is a structure that i have created in SE11 and for the quantity field i used component type as CHAR15 and has no decimals.

Shejal.

1 ACCEPTED SOLUTION
Read only

Manohar2u
Active Contributor
0 Likes
1,259

How the data is send as 4500? normally it should not.

Else like laxmana suggested.

Your final internal table data should have 4.500, for this whenever before you are sending data to external system move this data to new internal table, where you move quantity field to character field.

( should have standard interfacing format mapped, like decimal separater is dot or comma )

Regds

Manohar

11 REPLIES 11
Read only

Laxmana_Appana_
Active Contributor
0 Likes
1,259

Hi,

Change the data type of the quantity field to DEC with decimals , after sum , assign the value to character field.

Code :

data : i_input like ZSDINPUT occurs 0 with header line.

data : begin of i_process occurs 0,

fld1 like BSEG-ZBD1P,

end of i_process,

fld2 like BSEG-ZBD1P.

suppose if i_process contains data entries like 1.000,2.500

loop at i_process.

fld2 = fld2 + i_process-fld1.

endloop.

at last move fld2 to i_input table.

i_input-chrfld = fld2.

Laxman

Message was edited by: Laxmana Kumar

Read only

0 Likes
1,259

Thanks LAxman for your suggestion.

you mean change the char field in SE11 structure and then do the calculation and once the calculation is done change back to CHAR format in the program.

is that what you mean and if thats true how can that be done.

Is it this way,

once i am done with the calculations.

DAtA i_input-quantity like char.

Let me know more in detail.

Shejal.

Read only

Manohar2u
Active Contributor
0 Likes
1,260

How the data is send as 4500? normally it should not.

Else like laxmana suggested.

Your final internal table data should have 4.500, for this whenever before you are sending data to external system move this data to new internal table, where you move quantity field to character field.

( should have standard interfacing format mapped, like decimal separater is dot or comma )

Regds

Manohar

Read only

Former Member
0 Likes
1,259

Thanks Manohar,

Yaa i thinking of working like lakshman said. But my question is do i need to change my structure in SE11 and once i do the calculation change it back to a char format.

if yes can you guide me how. Do you mean to use 2 internal tables of the same structure.

Shejal.

Read only

Manohar2u
Active Contributor
0 Likes
1,259

No, you should not change the data types in SE11. You need two internal tables.

T1 - to do all manipulations in SAP

T2 - is a copy of T1 with changes of quantity to char fields for sending to external system.

Regds

Manohar

Read only

0 Likes
1,259

Shejal, you do not have to change anything in SE11. From your previous posts, I am under the assumption that you are working in the sales document user exit. These include programs are not set as "Fixed Point Arithmatic" This is the reason for the calculation being 4500 instead of 4.500. There are two ways to work your problem. One, which I would not recommend, is to set the "Fix Point Arithmatic" checkbox in the attributes of the main program. Doing so will fix your issue in the user exit, but may mess other things up. The other way is to do your calculating and divide by 1000. This is a safe way to go. If your fields in the calculation have 3 decimal places, then divide by 1000, if 2, then by 100 an so on.

<b>

result = ( value1 + value2 ) / 1000.

</b>

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,259

Thanks Max,

Its the easiest and i guess the safest method.

Thanks again.

Shejal.

Read only

Former Member
0 Likes
1,259

Thanks Rich.

Read only

Former Member
0 Likes
1,259

Hi Rich,

Yes i am working on the sales user Exit and as you have suggested, to just add the values and divide by 100 or 1000 which ever i need but when i do this the problem i have is its not getting me anything after the decimal. eg

1500.000 LBS and 1000.000 Lbs i get the result as 2500 LBS but i want it to be displayed as 2500.000 LBS.

Any Suggestions on this.

Shejal.

Read only

0 Likes
1,259

Then you need to do your calculation into a type p field, then move this to your charcter field.

data: c(15) type c.
data: p type p decimals 3.

p = ( value1 + value2 ) / 1000.

c = p.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,259

THanks everyone.

The problem is solved.

Thanks again.

Shejal.