Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Conversion of char to internal representation

I am extracting a field of char40 and creating a file out of it. The problem I have is

A99\260 Z1 50000700 SPECIFIC GRAVITY @ 15.6 C 1.0600

A99\260 Z1 50000751 BLOT (PASS) Clean

A99\260 Z1 50000757 CLARITY (CLEAR) Slight Haze Pass

A99\260 Z1 50000761 COLOR 3.0 typical L 0.5

A99\260 Z1 50000731 VISCOSITY @ 40 C, CST 69.00

A99\260 Z1 50000725 VISCOSITY @ 100 C, CST 8.300

As you can see the field values after the char field are been placed based on the actual length of the char field. I need to convert it to 40 chars so I can write the rest of the fields following it as a tabbed distance away. My file format gets whacked if one of the values is blank. How to fill them? Thanks

Message was edited by:

Megan Flores

Former Member
Former Member replied

Check the below program :

parameters: d1 type localfile default


data: begin of itab occurs 0,

field1(20) type c,

field2(20) type c,

field3(20) type c,

end of itab.

data: str type string.

constants: con_tab type x value '09'.

  • if you have a newer version, then you can use this



  • con_tab type c value



itab-field1 = 'ABC'.

itab-field2 = 'DEF'.

itab-field3 = 'GHI'.

append itab.

itab-field1 = '123'.

itab-field2 = '456'.

itab-field3 = '789'.

append itab.

open dataset d1 for output in text mode.

loop at itab.

translate itab using ' # '.

concatenate itab-field1 itab-field2 itab-field2

into str

separated by con_tab.

translate str using ' # '.

transfer str to d1.


close dataset d1.



0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question