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

Problem with File

Former Member
0 Likes
1,355

Hello Experts,

In our SAP system a file is uploaded to the FTP server through some program.The structure of the file is

MATNR & Net Weight

8-108-447-283|0,521

8-104-930-756|4,489

8-108-222-232|0,022

8-104-546-656|0,042

8-104-546-657|0,051

8-104-937-094|5,417

8-104-919-598|0,308

8-104-146-444|0,195

But when is it uploaded to the Apllication server.It displays like this:

8-108-447-283 0,521#

8-104-930-756 4,489#

8-108-222-232 0,022#

8-104-546-656 0,042#

8-104-546-657 0,051#

8-104-937-094 5,417#

8-104-919-598 0,308#

8-104-146-444 0,195#

8-104-145-877 5,316#

This # symbol is added at the end of every line.

My task is to update the Netweight of the Material thro' BAPI and it is working fine.

Because of this # I am getting dump when I am translating the Char format of weight to Quantity format.

If I try to replace the # symbol by space, The hash symbol is not reconginsed.

Please tell me a solution to avoid the hash symbol when uploading into my report.

Thanks in Advance.

Vasanth

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,332

Hi Vasanth

I guess the problem is the codepage mismatch between the source system and your system.

If you are working on Unicode System and the source system is NON-UNICODE, open the dataset with addition NON-UNICODE.

Unicode enabled system will show CR & LF characters as # when you try to view them in debugging.

Kind Regards

Eswar

Note: Reward for helpful answers

11 REPLIES 11
Read only

Former Member
0 Likes
1,332

Hi Vasanth,

As per me I have taken the structure that you have specified and done a little bit of programming so rather that passing the sturcture that you have specified specify the structure as

8-108-447-283 0,521

8-104-930-756 4,489

8-108-222-232 0,022

8-104-546-656 0,042

8-104-546-657 0,051

8-104-937-094 5,417

8-104-919-598 0,308

8-104-146-444 0,195

here the funda is to pass the material as 18 characters. though it includes only 13 characters that you have passed in the flat file.

Cheers,

Pedhadodi Sudhakar

Read only

Former Member
0 Likes
1,333

Hi Vasanth

I guess the problem is the codepage mismatch between the source system and your system.

If you are working on Unicode System and the source system is NON-UNICODE, open the dataset with addition NON-UNICODE.

Unicode enabled system will show CR & LF characters as # when you try to view them in debugging.

Kind Regards

Eswar

Note: Reward for helpful answers

Read only

sridharreddy_kondam
Active Contributor
0 Likes
1,332

Hi Vasanth,

Does the file from the application server has fixed length with 21 chars per line(including Hash)?

Have u tried with this

REPLACE FIRST OCCURRENCE OF '#' IN NetWeight WITH ''.

Regards,

Sridhar

Read only

0 Likes
1,332

Hi Sridhar,

I have tried like this.

<b>SPLIT L_F_LINE AT '|' INTO G_T_DATA-MATNR G_T_DATA-BRGEW.

REPLACE ALL OCCURRENCES OF '#' IN G_T_DATA-BRGEW WITH SPACE.</b>

But the problem is the # symbol is not recongised by the system.

Could u please tell me the solution for this.

Thanks

Vasanth

Read only

0 Likes
1,332

HI

'#' will not be recognized when you try to replace as it shows CR and LF as '#' characters in debugging whereas they are different characters. This is due to character type conversion in UNICODE enabled systems.

Kind Regards

Eswar

Read only

0 Likes
1,332

Hi Vasanth,

I have tried this and its working ...

data : G_T_DATA-MATNR type matnr,

G_T_DATA-BRGEW(6) type c.

data s1 type string.

s1 = 'abcdefgh | 23456#'.

SPLIT S1 AT '|' INTO G_T_DATA-MATNR G_T_DATA-BRGEW.

*REPLACE ALL OCCURRENCES OF '#' IN G_T_DATA-BRGEW WITH SPACE.

REPLACE FIRST OCCURRENCE OF '#' IN G_T_DATA-BRGEW WITH ''.

write G_T_DATA-BRGEW.

Regards,

Sridhar

Read only

0 Likes
1,332

Hello Eswar,

I am using this code to open the file from Application server

<b> CLEAR: G_T_DATA,L_F_LINE.

REFRESH: G_T_DATA.

OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

*DEFAULT.

IF SY-SUBRC EQ 0.

DO.

READ DATASET P_FILE INTO L_F_LINE.

IF SY-SUBRC = 0.

  • rpd2kor 09.08.06 -sm

G_T_DATA-MATNR = L_F_LINE(13).

WRITE L_F_LINE+14 TO G_T_DATA-BRGEW.

SHIFT G_T_DATA-BRGEW RIGHT DELETING TRAILING SPACE.

  • SPLIT L_F_LINE AT '|' INTO G_T_DATA-MATNR G_T_DATA-BRGEW.

  • REPLACE ALL OCCURRENCES OF '#' IN G_T_DATA-BRGEW WITH SPACE.

  • rpd2kor 09.08.06 -em

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

INPUT = G_T_DATA-MATNR

IMPORTING

OUTPUT = G_T_DATA-MATNR.

APPEND G_T_DATA.

CLEAR: G_T_DATA,L_F_LINE.</b>

Now what happends is when I am reading the line from <b>P_FILE the L_F_LINE = 8-108-447-283|0,521#</b>

What woulb be the probable error of the issue.

Thanks

Vasanth

Read only

0 Likes
1,332

Hello Sridhar,

As u said Its working for me if the I pass the string as

s1 = 'abcdefgh | 23456#'.

Since here s1 is having the hash symbol. But the # is not actually available when the file is imported to FTP server from CAD system. When it is added to the FTP server of the SAP system, the # symbol is automatically added at the end of the each line.

Thanks

Vasanth

Read only

0 Likes
1,332

Hi Vasanth,

Try using this statement...

<b>OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.</b>

DO.

READ DATASET P_FILE INTO v_string.

-->now use ur code either with REPLACE or the Function module

IF sy-subrc <> 0.

EXIT.

ENDIF.

Regards ,

Sridhar

Read only

0 Likes
1,332

Hi Vasanth

Can you try adding "IGNORING CONVERSION ERRORS". Also check if source system sends data in NON-UNICODE or UTF-8/16 format.

Kind Regards

Eswar

Read only

0 Likes
1,332

Dear Sridhar

You statement works if our SAP system and the system sending data both are of same type(UNICODE/NON-UNICODE) when itz different like ours UNICODE and the source NON-UNICODE your statement will not work.

Above is just for your information.

Kind Regards

Eswar