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

can i write a ztable directly?

hi

im having a ztable with some 'n' fields and i have entries for the same . now in my report prog. can i use the write: statement directly like this write: myztable or should i use write : myztable-field1,

myztable-field2, ..........................

if i have 150 fields then how can do the above for 150 times..

is there any other way for doing this.......

any help will be appreciated

regards

mano

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 09, 2008 at 02:11 PM

    Hi,

    Take one internal table and fetch the data into that.

    And then loop through the internal table and write.

    If all the fields are character type then you can do:

    write : it_ztab.

    otherwise you need to write required number of fiedls.

    code ;

    data : it_ztab type standarad table of ztab,

    wa_itab type ztab.

    select * from ztab into table it_ztab. (give where condition).

    loop at it_ztab into wa_itab.

    write : wa_itab (if all fields are character type).

    write : wa_itab-field1,

    wa_iatb-field2.....etc etc.

    endloop.

    Regards

    Sandeep Reddy

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 09, 2008 at 02:07 PM

    Hi Manoj,

    u need to use INSERT statement

    INSERT dbtab

    Syntax

    INSERT { {INTO target VALUES source }

    | { target FROM source } }.

    Effect

    The INSERT statement inserts one or more rows specified in source in the database table specified in target. The two variants with INTO and VALUES or without INTO with FROM behave identically, with the exception that you cannot specify any internal tables in source after VALUES.

    Best regards,

    raam

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Answer to your question is YES, if all the fields of the table are of character type. If you have any amount fields/quantity field you will get a syntax error 'Cannot be converted to character type' while activating.

      tables : ztest.
      
        select * from ztest.
        write / ztest.
        endselect.

      Above code will work if all the fields of ZTEST are of type character. if you want to avoid writing all the fields manually you can use the above mentioned code or retrieve the fields from DD03L and display as per your requirement.

      Hope this is helpful.

      Thanks,

      Pavan

  • author's profile photo Former Member
    Former Member
    Posted on Jun 09, 2008 at 02:09 PM

    FIELD-SYMBOLS <FIELD>.

    DO.

    ASSIGN COMPONENT sy-index OF STRUCTURE <your structure> TO <FIELD>.

    IF SY-SUBRC NE 0.

    EXIT.

    ENDIF.

    Write: <field>.

    ENDDO.

    Check the help for the ASSIGN keyword I have of types in incorrectly.

    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.