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

Validating tab delimited file

ajeet_choudhary
Participant
0 Likes
1,498

Hi,

I have to make a report that have to upload tab delimited file from presentation server and perform operation then.

Now, can anyone tell me:

1. how to validate if file is tab delimited at all or not?

2.how to check if file has correct data i.e. say in the incoming file there should be 18 column, all of them can be filled or not at a time. how to check if file has data for required column only?

Regards

Ajit C

Hi,

I have to make a report that have to upload tab delimited file from presentation server and perform operation then.

Now, can anyone tell me:

1. how to validate if file is tab delimited at all or not?

2.how to check if file has correct data i.e. say in the incoming file there should be 18 column, all of them can be filled or not at a time. how to check if file has data for required column only?

Regards

Ajit C

2 REPLIES 2
Read only

Former Member
0 Likes
1,016

Hi Ajeet,

For the first question, use SPLIT statement and use separator as cl_abap_char_utilities=>horizontal_tab. Check the sy-subrc value for validation.

Secondly, if your split statement works, then the values will be in respective columns of the structure u will be using in ABAP. Then you can place the validation based on the values in fields of structure.

For further clarification go through F1 help on split statement.

Thanks,

Sumit

Read only

Clemenss
Active Contributor
0 Likes
1,016

Hi Ajeet,

first do the GUI_UPLOAD into an internal table of text lines with sufficient length (i.e. text200 or so).

Declare a internal table of strings, i.e. lt_col type table of string.

Loop at the table just uploaded. For each line, SPLIT <line> BY cl_abap_char_utilities=>horizontal_tab INTO TABLE lt_col.

IF lines( lt_col ) = 0.

* NOT tab-delimited

  EXIT. "the loop

ELSE.

* Use the data

  LOOP AT lt_string ASSIGNING <string>.

    CASE sy-tabix.

      WHEN 1.

* columns 1

* ...

      WHEN 8.

        IF <string>  IS INITIAL.

* Expected value not present...

        ENDIF

    ENDCASE.

  ENDLOOP.

ENDIF.

This is just to give you an idea.

Regards,

Clemens