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

How transfer a string which has trailing zero's

Former Member
0 Likes
1,398

Hello All,

I have string which has trailing zeros. These string values should be stored in application server.

The problem is! when i save the file in the application server i am unable to these trailing zeros after saving the file in the application server.

So how can i handle this.

Thanks and regards,

Lisa.

9 REPLIES 9
Read only

Former Member
0 Likes
1,248

can you post the code how your transferring the file to application server??

Read only

0 Likes
1,248

Hi Chandrasekhar,

here is is the code

 
   OPEN DATASET file FOR OUTPUT IN TEXT MODE
    ENCODING NON-UNICODE IGNORING CONVERSION ERRORS.

the above is my transfer mode

and


      TRANSFER trans_file TO file LENGTH len.

Regards,

Lisa

Read only

mithun_shetty4
Contributor
0 Likes
1,248

Hi Lisa,

While transferring the String to Application Server ensure that your data is in the Character Format.

ie suppose you are Transferring an internal table which has Numc Fields which has leading Zeroes,now u need to Convert the Intrnal table fields to Char with similar length and decimal places ,

transfer this Internal table to File.

Hope this wil Solve your Problem.

Award Points if Useful.

Regrds,

Mithun

Read only

0 Likes
1,248

Hi Mithiun,

What do you mean by String must be in character format. Doest mean like below code must be there.

data i(200) type c.

Tranfer i to file.

If this is your question then i can't put trailing zeros. Do you have any idea how to put trailing zeros in this case.

Regards,

Lisa.

Read only

oliver
Active Contributor
0 Likes
1,248

Hi Lisa,

are this numbers after decimal point? Probably because of internal type definition. Same can happen to leading zeros. Are they part of some kind of order?

Best regards,

ok

Read only

Former Member
0 Likes
1,248

Hello oliver,

These numbers are not after decimals.

Regards,

Lisa.

Read only

Former Member
0 Likes
1,248

Lisa,

What is the data structure of "trans_file"?

Read only

uongf
Discoverer
0 Likes
1,248

HI Lisa,

not sur eif this is exactly what you need, but i was able to write trailing 0's with this example:

data: s1(50) type c,

s2 type c value ' ',

z1 type c value '0',

l1 type i.

data: f1(50) value 'test_file'.

clear: s1.

move: '123456789' to s1.

l1 = strlen( s1 ).

do 50 times. "(or replace with a value of s1 max len (50) - l1 )

replace ' ' in section offset l1 length 1 of s1 with '0'.

enddo.

open dataset f1 for output in text mode encoding non-unicode.

transfer s1 to f1.

close dataset f1.

-


not quite an elegant piece of code but hope this helps!

best regards,

fredy

Read only

Former Member
0 Likes
1,248

Hi,

I guess trailing zero's were also transfered to your file(app server)may be some part of the record only visible to you.

so download the file into presentation server using CG3Y transaction in asci mode and check file whether file contains the leading zero's or not....

reward if needful...