09-05-2008 3:58 PM
Hi ,
We are passing a data in table to the application server
I have a variable zipcode in the table
it is described as
final_tab-zip = p0006-pstlz(5).
"zip is decalred as zip(5)
Now I am passing the table as comma delimited file to application server.
The problem is in the process..we are loosing the leading zeroes..
if say zip is 08801..
we see it as 8801...
How can we preserve the leading zeroes when we transfer the data..
Any change need to be done while decalration or transfer..
Thank you.
09-05-2008 4:00 PM
How are you passing the line?
Are you just trasfering the whole structure or you move each field to the line with a string?
09-05-2008 4:03 PM
I am moving the field to the string and passing it to the file
code is like this
LOOP AT final_tab.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE pm_tab TO <fs>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF sy-index EQ 22.
IF <fs> NE space.
CONCATENATE string <fs> INTO string.
ENDIF.
ELSEIF sy-index EQ 1.
IF <fs> EQ space.
MOVE ',' TO string.
ELSE.
CONCATENATE string <fs> ',' INTO string.
ENDIF.
ELSE.
IF <fs> EQ space.
CONCATENATE string ',' INTO string.
ELSE.
CONCATENATE string <fs> ',' INTO string.
ENDIF.
ENDIF.
ENDDO.
APPEND string TO itab .
CLEAR string.
ENDLOOP.
Edited by: KUMAR BOJEDLA on Sep 5, 2008 11:10 AM
09-05-2008 4:13 PM
Doesn't seem to be a problem, as long as in the debug you are getting the zeros.
As the other poster said, If you are opening in Excel it formats the info. If you want the zeros you will need to confuse excel by placing a symbol in the number so it is treated as a string
09-05-2008 4:30 PM
Yes ..It is saved as csv...
and I open it from the server on the desktop..
That may be the reason,
but I wonder is there no way that we can see leading zeroes in the excel.
And I have field with char1 which is populated with 1 and 0 and it is displayed fine..
So is it that if there is only 1 zero we can see it in excel
09-05-2008 4:37 PM
On your Application Server Destop, follow this steps to open it without loosing leading zero
1. Start the Excel .. Progrmas > Run > Excel
2. From Open, select your file.
3. Now system will bring the popup for the "Text to Column"
4. Select the Delimited .. Press Next
5. Select Comma as the delimitator .. Press Next
6. Here Select the column of the Zip code or all ... and select the radiobutton "TEXT"
7. Finish.
By this way, you will retain the Leading Zero in the Excel.
Regards,
Naimesh Patel
09-05-2008 4:37 PM
Excel takes out leading zeroes....not all zeroes.
There is no easy solution for this.
One possible solution is to append some character say for example a dot "." in front of the zipcode, so that excel will take it as a string and not a number.
instead of sending 08816 you have to send .08816 , but the dot will be shown at the output if that is acceptable....or transfer it to a text file, and use the text import wizard of excel which will take care of the leading zereos
09-05-2008 5:18 PM
Naimesh,
When i opened the excel ,I can directly open the excel file...
I could not see any pop up ....
09-05-2008 5:25 PM
Since it is a CSV file, excel will not ask for the "Text Import Wizard".
If the file is in the TXT than it will ask for the wizard.
For trial:
Copy your file and rename it to .txt
Now, perform the steps with this TXT file.
If you are ok, than save your file as TXT file on the application server.
Regards,
Naimesh Patel
09-05-2008 6:44 PM
Thank you naimesh..
It worked.
But this file be seen by the clients..
So We are not sure that they would check all these procedure to view the file!?
So if it is in csv..THey could now open the file in excel..
If it is text then they should entire procedure each time...
I will share it across...
Friends let me know... if you see any other possibilities...
Thanks a lot for the replies...
09-05-2008 4:10 PM
How do you open the file?...I mean do you get the file from the app server to presentation server and then open in Excel??....In that case the problem is not with your code. The problem is with Excel...Excel truncates all leading zeroes.