Application Development 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: 

Regarding Upload of data into SAP from Application server using DATA SETS

Former Member
0 Kudos

Hi all,

I have a problem when uploading data that is application server [.txt file] into SAP using OPEN DATA SET,READ DATA SET & CLOSE DATA SET it is now going to dump. The file is actually splits the fields by using Tab Delimiter.

During uploading some junk values are coming with '#' so it going to dump and giving follow type of error.

Runtime Errors CONVT_NO_NUMBER

Exception CX_SY_CONVERSION_NO_NUMBER

Unable to interpret "#0#0#0#0#0#0#0#" as a number.

Can any one solve the above issue as i need it urgently.

Thanks in advance.

Thanks & Regards,

Rayeezuddin.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Dear Rayeezuddin,

Dont try take it for grant that tabs and spaces are same and it is constant. Tabs may vary from PC to PC.

You have to use a special Tab Character to delimit your file.

If you are using 4.6 version you can do

data : tab_char type x value '09'.

.....

read the line in a character string.

split <var> at tab_char into var1 var2 var3 var4.

If you are using 4.7 version, you can do

CLASS cl_abap_char_utilities DEFINITION LOAD.

....

read the line in a character string.

split <var> at cl_abap_char_utilities=>horizontal_tab into var1 var2 var3 var4.

I hope this will help .

Please let me know in case of any problem

Regards

Mitesh

15 REPLIES 15

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

How are you reading it in, in binary mode? Post your code and a sample file.

Regards,

Rich Heilman

0 Kudos

Hi,

The main part of code as follows:

FORM f_get_legacy_data .

OPEN DATASET v_pfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.

  • IF sy-subrc <> 0.

  • MESSAGE text-207 TYPE c_e.

  • ELSE.

DO.

CLEAR wa_input1.

  • READ DATASET v_pfile INTO wa_input1.

READ DATASET v_pfile INTO wa_read.

IF sy-subrc EQ 0.

*Begin of change done by Rama Krishna. N (F80078) 07/08/2005-D5SK911773

  • To make the Legacy file 'Tab Delimited'

wa_input1-vbeln = wa_read+0(10).

wa_input1-posnr = wa_read+18(6).

wa_input1-PER0BAL = wa_read+32(15).

wa_input1-PER1VAL = wa_read+55(15).

wa_input1-PER2VAL = wa_read+78(15).

wa_input1-PER3VAL = wa_read+101(15).

wa_input1-PER4VAL = wa_read+124(15).

wa_input1-PER5VAL = wa_read+147(15).

wa_input1-PER6VAL = wa_read+170(15).

wa_input1-PER7VAL = wa_read+193(15).

wa_input1-PER8VAL = wa_read+216(15).

wa_input1-PER9VAL = wa_read+239(15).

wa_input1-PER10VAL = wa_read+262(15).

wa_input1-PER11VAL = wa_read+285(15).

wa_input1-PER12VAL = wa_read+308(15).

*&--


End of change--


APPEND wa_input1 TO i_input1.

CLEAR wa_input1.

ELSE.

EXIT.

ENDIF.

ENDDO.

  • ENDIF.

CLOSE DATASET v_pfile.

IF i_input1[] IS INITIAL.

  • If there is no data in the legacy file or if the structure of the

  • legacy data does not match with that of internal table error message

  • need to be displayed.

MESSAGE text-211 TYPE c_e.

*&--


begin of change--


ELSE.

CLEAR: wa_input, wa_input1.

LOOP AT i_input1 INTO wa_input1.

  • MOVE wa_input1 TO wa_input.

MOVE: wa_input1-vbeln TO wa_input-vbeln,

wa_input1-posnr TO wa_input-posnr,

wa_input1-per0bal TO wa_input-per0bal,

wa_input1-per1val TO wa_input-per1val,

wa_input1-per2val TO wa_input-per2val,

wa_input1-per3val TO wa_input-per3val,

wa_input1-per4val TO wa_input-per4val,

wa_input1-per5val TO wa_input-per5val,

wa_input1-per6val TO wa_input-per6val,

wa_input1-per7val TO wa_input-per7val,

wa_input1-per8val TO wa_input-per8val,

wa_input1-per9val TO wa_input-per9val,

wa_input1-per10val TO wa_input-per10val,

wa_input1-per11val TO wa_input-per11val,

wa_input1-per12val TO wa_input-per12val.

APPEND wa_input TO i_input.

CLEAR: wa_input, wa_input1.

ENDLOOP.

ENDIF.

ENDFORM. " GET_LEGACY_DATA

Sample Data:

Directory /pw/data/erp/D5S/fi/up

Name: Backlog1616_D1S.txt

-


1st Record

BKCOPO1 BKSOI1 1000.00 100.00 -200.00 0 0 0 0 0 0 0

2nd Record

BKSOPO2 BKSOI2 2222.22 0 300 0 0 0 0 0 0 0

3rd Record

BKSOPO3 BKSOI3 -3000 400 0 0 0 0 0 0 0 0

4th Record

BKSOPO4 4000.55 500 600 0 0 0 0 0 0 0

5th Record

0040000000 000010 -100 -110 -110 0 0 -600 0 0 0 0

6th Record

0040000001 000010 -110 -110 0 0 0 -610 0 0 0 0

the above records are need to be uploaded please give me solution.

Thanks,

Rayeezuddin

0 Kudos

Hi Heilman,

Have you got any solution for the problem i posted in this site [Dump during upload of data from application server to SAP].

Thanks,

Rayeezuddin.

0 Kudos

I have try to re-create you problem with the data that you have provide, I have a # in the first record, but that is it. The internal table is filled correctly. I would suggest making your file comma delimited instead of tab delimited, as it would be easier and cleaner.

Here is my test program.




report zrich_0001.

data:  xrec(1000) type c.

data: begin of itab occurs 0,
      a(20) type c,
      b(20) type c,
      c(20) type c,
      d(20) type c,
      e(20) type c,
      f(20) type c,
      g(20) type c,
      h(20) type c,
      i(20) type c,
      j(20) type c,
      k(20) type c,
      l(20) type c,
      m(20) type c,
      n(20) type c,
      o(20) type c,
      end of itab.

data: path(100) type c.

path = '/QDLS/ALH/test.txt'.

open dataset path for input in text mode.

do.
  clear xrec.

  read dataset path into xrec.
  if sy-subrc <> 0.
    exit.
  endif.

  split xrec  at ',' into itab-a itab-b itab-c itab-d itab-e itab-f
                          itab-g itab-h itab-i itab-j itab-k itab-l
                          itab-m itab-n itab-o.

  append itab.

enddo.

close dataset path.

Here is my test file.



BKCOPO1,BKSOI1,1000.00,100.00,-200.00,0,0,0,0,0,0,0
BKSOPO2,BKSOI2,2222.22,0,300,0,0,0,0,0,0,0
BKSOPO3,BKSOI3,-3000,400,0,0,0,0,0,0,0,0
BKSOPO4,4000.55,500,600,0,0,0,0,0,0,0
0040000000,000010,-100,-110,-110,0,0,-600,0,0,0,0
0040000001,000010,-110,-110,0,0,0,-610,0,0,0,0


Regards.

Rich Heilman

0 Kudos

HI Heilman,

Thank you for that reply.

Because test data is already given to us with Tab delimiter format i might not be able to work with (,)delimiter format.

I know the problem is with Tab Delimiter only and getting #'s in the table lines. but can't we work with Tab delimeter without getting that dump.

Please try to solve my problem with Tab Delimeter file only.

again thank you very much for all your efforts for solving my issue.

If u want entire code for testing please give me your personnel mail ID.

Thanks,

Rayeezuddin.

0 Kudos

I don't think that the dump is coming from the actual reading of the file. It is coming because you are trying to move character data to a field that is numeric of some type(N, I, P). This is where you are getting your ABAP dump. The # signs are the tabs in your file. You will need to t split at the # sign instead of comma. The offsets that you are using to move the data into the internal table will not work. You need to split at the #.


DO.
CLEAR wa_input1.
* READ DATASET v_pfile INTO wa_input1.
READ DATASET v_pfile INTO wa_read.

IF sy-subrc EQ 0.

split wa_read at '#' into 
wa_input1-vbeln 
wa_input1-posnr 
wa_input1-PER0BAL 
wa_input1-PER1VAL
wa_input1-PER2VAL
wa_input1-PER3VAL 
wa_input1-PER4VAL 
wa_input1-PER5VAL 
wa_input1-PER6VAL 
wa_input1-PER7VAL 
wa_input1-PER8VAL
wa_input1-PER9VAL 
wa_input1-PER10VAL 
wa_input1-PER11VAL 
wa_input1-PER12VAL.

APPEND wa_input1 TO i_input1.
CLEAR wa_input1.
ELSE.
EXIT.
ENDIF.
ENDDO.

Regards,

Rich Heilman

0 Kudos

Hi Hielman,

Thnaks for that reply and for effort you are putting to solve my issue.

I had done the same thing what u have posted prior to your reply but still i am getting dump.

FORM f_get_legacy_data .

DATA: l_tab type xstring,

l_tab1(1) type c,

s type x.

move '23' to l_tab.

move l_tab to l_tab1.

  • OPEN DATASET v_pfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.

OPEN DATASET v_pfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.

  • IF sy-subrc <> 0.

  • MESSAGE text-207 TYPE c_e.

  • ELSE.

DO.

CLEAR wa_input1.

  • READ DATASET v_pfile INTO wa_input1.

READ DATASET v_pfile INTO wa_read.

IF sy-subrc EQ 0.

move wa_read to i_txt-txt.

append i_txt.

ELSE.

EXIT.

ENDIF.

ENDDO.

s = '09'.

loop at i_txt.

  • move i_txt-txt+10(1) to l_tab1.

  • move '#' to l_tab1.

  • split i_txt-txt at s into wa_input1-vbeln wa_input1-posnr

split i_txt-txt at '#' into wa_input1-vbeln wa_input1-posnr

wa_input1-per0bal wa_input1-per1val

wa_input1-per2val wa_input1-per3val

wa_input1-per4val wa_input1-per5val

wa_input1-per6val wa_input1-per7val

wa_input1-per8val wa_input1-per9val

wa_input1-per10val wa_input1-per11val

wa_input1-per12val.

APPEND wa_input1 TO i_input1.

CLEAR wa_input1.

endloop.

  • ENDIF.

CLOSE DATASET v_pfile.

IF i_input1[] IS INITIAL.

  • If there is no data in the legacy file or if the structure of the

  • legacy data does not match with that of internal table error message

  • need to be displayed.

MESSAGE text-211 TYPE c_e.

*&--


begin of change--


ELSE.

CLEAR: wa_input, wa_input1.

LOOP AT i_input1 INTO wa_input1.

  • MOVE wa_input1 TO wa_input.

MOVE: wa_input1-vbeln TO wa_input-vbeln,

wa_input1-posnr TO wa_input-posnr,

wa_input1-per0bal TO wa_input-per0bal,

wa_input1-per1val TO wa_input-per1val,

wa_input1-per2val TO wa_input-per2val,

wa_input1-per3val TO wa_input-per3val,

wa_input1-per4val TO wa_input-per4val,

wa_input1-per5val TO wa_input-per5val,

wa_input1-per6val TO wa_input-per6val,

wa_input1-per7val TO wa_input-per7val,

wa_input1-per8val TO wa_input-per8val,

wa_input1-per9val TO wa_input-per9val,

wa_input1-per10val TO wa_input-per10val,

wa_input1-per11val TO wa_input-per11val,

wa_input1-per12val TO wa_input-per12val.

APPEND wa_input TO i_input.

CLEAR: wa_input, wa_input1.

ENDLOOP.

ENDIF.

ENDFORM. " GET_LEGACY_DATA

When i am giving input as

Directory /pw/data/erp/D5S/fi/up

Name: Backlog1616_D1S.txt

-


BKCOPO1 BKSOI1 1000.00 100.00 -200.00 0 0 0 0 0 0 0

BKSOPO2 BKSOI2 2222.22 0 300 0 0 0 0 0 0 0

BKSOPO3 BKSOI3 -3000 400 0 0 0 0 0 0 0 0

BKSOPO4 4000.55 500 600 0 0 0 0 0 0 0

0040000000 000010 -100 -110 -110 0 0 -600 0 0 0 0

0040000001 000010 -110 -110 0 0 0 -610 0 0 0 0

I am getting i_input internal table populated as follows at the end of that subroutine.

After appending [APPEND wa_input TO i_input].

BKCOPO1#BK|000000| 0.00 | 0.00 | 0.00 |

BKSOPO2#BK|000000| 0.00 | 0.00 | 0.00 |

BKCOPO3#BK|000000| 0.00 | 0.00 | 0.00 |

BKCOPO4##4|000000| 0.00 | 0.00 | 0.00 |

0040000000|000000| 0.00 | 0.00 | 0.00 |

0040000001|000000| 0.00 | 0.00 | 0.00 |

And output is showing erronious records: 6

No entries inserted.

Can you solve this issue.

Former Member
0 Kudos

Are you using the addition IN TEXT MODE with OPEN DATASET?

0 Kudos

Hi Jason,

It is in TEXT MODE only.

I had also provided main part of code also.

Please give me a feasable solution.

Thanks & Regards,

Rayeezuddin.

Former Member
0 Kudos

Hi,

The tab is read in SAP system as hex char '09'. I have written this code to read tab delimited file from presentation server.

It should work for Datasets also.

REPORT test.

DATA : s type x.

DATA : BEGIN OF itab OCCURS 0,

line(255) TYPE c,

END OF itab.

DATA : BEGIN OF itab1 OCCURS 0,

l1(30),

l2(30),

l3(30),

l4(15),

l5(15),

END OF itab1.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'H://testtab.txt'

  • FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = itab

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

s = '09'.

LOOP AT itab.

SPLIT itab-line AT s INTO itab1-l1 itab1-l2

itab1-l3 itab1-l4 itab1-l5.

APPEND itab1.

WRITE: /1 itab1-l1, itab1-l2, itab1-l3, itab1-l4, itab1-l5.

ENDLOOP.

My input file looked like this :

asdas asd asd 123 22

asdas dfs cdsgre 12 44

ewrg qwe nbyh 34 12

asdfa 12 123 453 123

Reagrds,

Gagan

0 Kudos

HI Gagan,

I had tried with your scenario also.

Still it is going for dump.

Thanks for your efforts.

Thanks,

Rayeez.

Former Member
0 Kudos

Dear Rayeezuddin,

Dont try take it for grant that tabs and spaces are same and it is constant. Tabs may vary from PC to PC.

You have to use a special Tab Character to delimit your file.

If you are using 4.6 version you can do

data : tab_char type x value '09'.

.....

read the line in a character string.

split <var> at tab_char into var1 var2 var3 var4.

If you are using 4.7 version, you can do

CLASS cl_abap_char_utilities DEFINITION LOAD.

....

read the line in a character string.

split <var> at cl_abap_char_utilities=>horizontal_tab into var1 var2 var3 var4.

I hope this will help .

Please let me know in case of any problem

Regards

Mitesh

0 Kudos

Hi Mitesh,

The resolution you have given has worked for me.

We have used following resolution.

If you are using 4.7 version, you can do

CLASS cl_abap_char_utilities DEFINITION LOAD.

....

read the line in a character string.

split <var> at cl_abap_char_utilities=>horizontal_tab into var1 var2 var3 var4.

once again Thanks for that reply.

Thanks,

Rayeezuddin.

Former Member
0 Kudos

Hi,

You need to get the hex code for '#' coming from the file as it is not # char but a control char. When reading file , put a breakpoint at read statement, then check the contents of the line and note the position of #. Then change the display to hex,( there is buttom on the right on filed content fields in debugging mode ). get the hex code for #. Remember that there are 2 char in hex per one char in character format. Get the code and use the code I have written above. just replace 09 in s = '09' with the code you got for '#'. I hope it works for you.

In my system code '09' is working perfectly.

Regards,

Gagan

Former Member
0 Kudos

Hi all,

Thanks all the guys who had worked for this isuue resolution.

Thanks again for all your efforts.

Thanks,

Rayeezuddin.