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: 

can i write a ztable directly?

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

8 REPLIES 8

Former Member
0 Kudos

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

0 Kudos

HI,

IM NOT TRYING TO INSERT RECORDS IN MY ZTABLE, I WANT TO USE MY ZTABLE IN MY PROG AND TRYING TO PRINT THE VALUES OF ZTABLE IN MY PROG. OUTPUT

0 Kudos

sorry, i couldnt understand ur solution can u elaborate the same...........

0 Kudos

Have you tried my solution.

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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