cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot read the whole date in read dataset

Former Member
0 Kudos

Hi Experts,

I am working on inbound program. My flat file is in text format.

I am reading the file in a string. This file contains date, time and employee number. When I read this file in a string preceding zeros are not read.

I mean if the date is 05/08/2007 it reads only 5/8/2007.

Can anyone please help me. its urgent. Thanks

Accepted Solutions (1)

Accepted Solutions (1)

naimesh_patel
Active Contributor
0 Kudos

May be your file doesn't contains the leading zeros.

Please check out the file.

Regards,

Naimesh Patel

Former Member
0 Kudos

I have leading zeros in my file. I want to know how we read date if we use ecc 6.0 using READ DATASET. Its reading everything but preceeding zeros. if its year then its reading as 2007. As i said before if the date is 05/08/2007 in the file then its reading 5/8/2007. pls respond

Answers (4)

Answers (4)

Former Member
0 Kudos

Guys,

Thanks alot for your suggestions. The problem is solved.

Former Member
0 Kudos

Please post your data declarations, your read logic and your output logic pertaining to these fields. If you have all the declarations as char type and you are reading the file in text mode, you should not see this behaviour.

Former Member
0 Kudos

REPORT zamag_inbound.

TABLES: cc1tev, pa0000.

DATA: read_line(500).

DATA: BEGIN OF amag_in OCCURS 0,

indic(3),

  • empty_1(45),

ldate type dats,

  • empty_2(1),

ltime type tims,

  • empty_3(8),

pernr LIKE pa0000-pernr,

  • empty_4(52),

clcki(2),

  • empty_5(6),

END OF amag_in.

*Data: p_file type string value'09'.

Data: k1 TYPE dats,

k2 type tims,

k3 type string,

k4 type string,

k5 type string.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

PARAMETERS:

p_file TYPE salfile-longname.

SELECTION-SCREEN END OF BLOCK blk1.

&----


START-OF-SELECTION.

&----


PERFORM upload_file.

&----


END-OF-SELECTION.

&----


LOOP AT amag_in.

WRITE: / amag_in-indic,

amag_in-ldate,

amag_in-ltime,

amag_in-pernr,

amag_in-clcki.

ENDLOOP.

&----


*& Form UPLOAD_FILE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_file .

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

DO.

READ DATASET p_file INTO read_line.

IF sy-subrc = 0.

  • write read_line9+(10) to k1 as

k1 = read_line+9(10).

k2 = read_line+19(5).

k3 = read_line+26(6).

K4 = read_line+39(2).

  • SPLIT read_line AT tab_1 INTO amag_in-indic

    • amag_in-empty_1

  • amag_in-ldate

    • amag_in-empty_2

  • amag_in-ltime

    • amag_in-empty_3

  • amag_in-pernr

    • amag_in-empty_4

  • amag_in-clcki

    • amag_in-empty_5.

APPEND amag_in.

  • IF sy-subrc = 0.

  • APPEND amag_in.

  • ELSE.

  • EXIT.

else.

exit.

ENDIF.

ENDDO.

  • ENDIF.

ENDFORM. " UPLOAD_FILE

Former Member
0 Kudos

For starters, do this:

k2 = read_line+19(6).     "<==== 6, not 5

And check the starting position when assigning k1.

Rob

Message was edited by:

Rob Burbank

former_member194669
Active Contributor
0 Kudos

Hi,

Try with declaration as character


Data: k1 TYPE string,   "<<<<
k2 type string,              "<<<<  
k3 type string,
k4 type string,
k5 type string.

Former Member
0 Kudos

Guys thanks for your suggestions but I have already tried those with same result. Will there be any settings in SAP or change in syntax for ECC 6.0. I dont know whats wrong in the coding. Points will be rewarded for your suggestions though.

Former Member
0 Kudos

I don't think you are assigning fields correctly. Would you please post one record from your file in code format (ie press the code button with the record highlighted).

Rob

Former Member
0 Kudos

You should not define date and time as type dats and tims respectively when you are uploading the file because you are getting the date in 10 character and probably time in 8 character format and the dats is 8 character and tims is 6 character data types.

Declare your internal table(with fields of char type and lenghts matching that of the file fields) to fit to your file format and upload the contents and then format them to the format you need for furhter processing.

Former Member
0 Kudos

Something like this,

DATA: BEGIN OF amag_in OCCURS 0,

indic(3),

ldate(10),

ltime(8),

pernr LIKE pa0000-pernr,

clcki(2),

END OF amag_in.

Former Member
0 Kudos

Where do you actually see that the zeroes are missing - a report, debugging, a download??

Rob

Former Member
0 Kudos

Debugging and also in report.

Former Member
0 Kudos

Hi,

Please check in your file, whether the data with the preciding ZERO or what,,,, and if that is ok then just define the date as CHAR so that what ever you specify will be displaye.

Thanks

Yogesh

Former Member
0 Kudos

I am reading whole thing as char its the same result.