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

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

Former Member
3 REPLIES 3
Read only

Former Member
0 Likes
561

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.

Read only

rahul_kamble2
Participant
0 Likes
561

Hi,

Please try statement READ REPORT......

Regards,

Rahul

Read only

Former Member
0 Likes
561

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