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: 

write a program that prints out its own source code hw do i do this

Former Member
3 REPLIES 3

Former Member
0 Kudos

Try this code:

DATA itab TYPE TABLE OF string WITH HEADER LINE.

READ REPORT sy-repid INTO itab.

LOOP AT itab.

WRITE: /1 itab.

ENDLOOP.

rahul_kamble2
Participant
0 Kudos

Hi,

Please try statement READ REPORT......

Regards,

Rahul

Former Member
0 Kudos

hi mehta,

The question does not really test a skill of a programmer, as much as general awareness of tricks to do that. In case you were wondering, a program whose output is its own source code is called a quine, something that might come of use over the next interview. The aforementioned Quine Page lists the following example for C:

charf="charf=%c%s%c;main()

{printf(f,34,f,34,10);}%c";

main(){printf(f,34,f,34,10);}

use abap methodology for the above.try..

if you wont do it,reply me. i will give you the code. but try.ok

thanks

sagar