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

Common Include

madhu_reddy22
Participant
0 Likes
1,068

HI Guys,

i have written a common include which should be used by any program. The include consists of generating the spool and writing to PDF.

But i have a problem with the piece of code below

IF WF_VALID <> SPACE.

NEW-PAGE PRINT ON PARAMETERS WF_PARAMS NO DIALOG.

LOOP AT IT_EMP INTO WA_EMP.

WRITE:/ WA_EMP-ORT01, WA_EMP-ORT02 " Output written to Spool

ENDLOOP.

NEW-PAGE PRINT OFF.

ENDIF .

The write statement cannot be common for all the programs. And i cannot write this in the main programs as it is in the middle of the include. Is there any solution for this.

Thanks in advance

madhu reddy

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
973

Then simply write the condition :

<b>if sy-cprog = program name</b>. ( Here you can mention program names which ever you want)

LOOP AT IT_EMP INTO WA_EMP.

WRITE:/ WA_EMP-ORT01, WA_EMP-ORT02 " Output written to Spool

ENDLOOP.

endif.

Thanks

Seshu

6 REPLIES 6
Read only

Former Member
0 Likes
974

Then simply write the condition :

<b>if sy-cprog = program name</b>. ( Here you can mention program names which ever you want)

LOOP AT IT_EMP INTO WA_EMP.

WRITE:/ WA_EMP-ORT01, WA_EMP-ORT02 " Output written to Spool

ENDLOOP.

endif.

Thanks

Seshu

Read only

0 Likes
973

HI Seshu,

Thanks a lot for the quick response. So you mean to say that if 4 people use the include. Then they can write their own statements using this condition in the include so that the remaining part of the include will function the same way.The number of write statements will increase but the remainig code will be same. Am i interpreting correctly?

So it will be like

IF WF_VALID <> SPACE.

NEW-PAGE PRINT ON PARAMETERS WF_PARAMS NO DIALOG.

if sy-cprog = program name

write: xxxxxxxxxx

endif

if sy-cprog = program name

write: xxxxxxxxxx

endif

if sy-cprog = program name

write: xxxxxxxxxx

endif

NEW-PAGE PRINT OFF.

ENDIF .

Thanks

Read only

0 Likes
973

Hello Madhu,

Yes,because you said that you will not modify in main program then best would be maintain the condition in include.

if you use SY-CPROG then it gets the program name from called program(Main program),

so you can write the condition so that your write statement will trigger only few programs.

Thanks

Seshu

Read only

Former Member
0 Likes
973

Hi madhu ,

You can copy this include in your program and perform and delete unwanted write statements.

Read only

0 Likes
973

HI Narayan,

you got me wrong. The same include should be used and it should not be copied as i am writing the common include to reduce the redundancy of the code.

Seshu has provided a great tip for that. Check that.

Thanks a lot.

Read only

Former Member
0 Likes
973

HI,

you can do like this.

if you include name is Zinclude, then,

Perform print_program(Zinclude) using ls_data

changing lt_output.

Regards,

Niyaz