Skip to Content
author's profile photo Former Member
Former Member

Structure

HI Friendz,

i am trying to create a structure using abap program,

but after executing the program, Structure is created, but the first field(FIELD1) is missing, pls any one help me... this is my code

<b>points for sure</b>

Thanks and Regards,

Vijaya

DATA: my_row(500) TYPE c,

my_file_1 LIKE my_row OCCURS 0 WITH HEADER LINE.

DATA: dd02v TYPE dd02v.

DATA: my_file_tab1 LIKE dd03p OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text

NO INTERVALS.

PARAMETERS:

name TYPE ddobjname,

testo TYPE text40,

file_1 LIKE rlgrap-filename.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN END OF BLOCK blk.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR file_1.

PERFORM file_selection USING file_1.

INITIALIZATION.

text = text-001.

START-OF-SELECTION.

IF file_1 IS INITIAL.

MESSAGE ID 'Z0017_BDI' TYPE 'I' NUMBER 001.

EXIT.

ENDIF.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = file_1

filetype = 'ASC'

TABLES

data_tab = my_file_1.

IF sy-subrc <> 0.

MESSAGE ID 'Z0017_BDI' TYPE 'I' NUMBER 002.

EXIT.

ENDIF.

LOOP AT my_file_1.

IF sy-tabix Gt 1.

CLEAR my_file_tab1.

SPLIT my_file_1 AT ';' INTO

my_file_tab1-fieldname

my_file_tab1-datatype

my_file_tab1-leng

my_file_tab1-decimals

my_file_tab1-ddtext

.

my_file_tab1-inttype = 'C'.

my_file_tab1-intlen = my_file_tab1-leng.

my_file_tab1-tabname = name.

my_file_tab1-position = sy-tabix - 1.

my_file_tab1-ddlanguage = sy-langu.

my_file_tab1-outputlen = my_file_tab1-leng.

APPEND my_file_tab1.

ENDIF.

ENDLOOP.

dd02v-tabname = name.

dd02v-ddlanguage = sy-langu.

dd02v-tabclass = 'INTTAB'.

dd02v-ddtext = testo.

dd02v-masterlang = sy-langu.

IF NOT my_file_tab1[] IS INITIAL.

CALL FUNCTION 'DDIF_TABL_PUT'

EXPORTING

name = name

dd02v_wa = dd02v

TABLES

dd03p_tab = my_file_tab1

EXCEPTIONS

tabl_not_found = 1

name_inconsistent = 2

tabl_inconsistent = 3

put_failure = 4

put_refused = 5

OTHERS = 6.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ELSE.

*MESSAGE ID 'Z0017_BDI' TYPE 'I' NUMBER 003.

MESSAGE s100 WITH 'Structure created succesfully'.

EXIT.

ENDIF.

&----


*& Form file_selection

&----


  • -->P_FILE_1 text

----


FORM file_selection USING p_file.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = ''

def_path = 'c:\'

mask = ',.,..'

mode = '0'

title = 'Selezione file'

IMPORTING

filename = p_file

  • RC = RCODE

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

ENDFORM. " file_selection

*And here is the file...

*

*Fieldname;Data Type;Lentgh;Dec.;Descr.

*FIELD1;CHAR;000020;000000;my field 1

*FIELD2;CHAR;000008;000000;my field 2

*FIELD3;CHAR;000007;000000;my field 3

*FIELD4;CHAR;000006;000000;my field 4

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 23, 2007 at 09:18 AM

    you are looping from second record , so obviously the first record will not be used , remove the one in bold

    LOOP AT my_file_1.

    <b>IF sy-tabix Gt 1.</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 23, 2007 at 09:28 AM

    Hi Vijaya,

    Do you want to check the sy-tabix count?

    if yes then do this'

    loop at my_file_1.

    if sy-tabix GE 1.

    endif.

    endloo.

    Greater than or equal to option will fetch you from the first record.

    Reward all helpful answers.

    Regards,

    Varun.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 23, 2007 at 09:31 AM

    YOu can as well remove the sy-tabix GT 1 and corresponding endif statement from the code.

    Does your file contain a header record?

    Regards,

    ravi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 23, 2007 at 09:32 AM

    Hi Vijaya,

    I tried with your code and found it got created with all the fields.

    Just try to execute once again and test. It will create the first field also.

    Regards,

    Krishna K

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 23, 2007 at 09:33 AM

    Hi Vijaya,

    The position ur passing should be <b>sy-tabix</b> not <b>sytabix-1</b> and remove if statement <b>'IF sy-tabix Gt 1.' 'endif'</b> . it will work fine.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.