cancel
Showing results for 
Search instead for 
Did you mean: 

calling different pages in a single sap script based on conditions?

Former Member
0 Kudos

Hi All,

Can anyone please give me an example of how to call different pages in a single sap script based on condition. Eg., i need to call 5 differnet pages from a single sap script based on 5 company codes.

Please help

Regards

Priya

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I'm not sure how to do this in sapscript.

Anyway, I would like to propose a workaround for you.

How about you combine all 5 formats in different text elements of MAIN window.

Later, you print program will determine which text element to call for specified company.

In the text element, it will check whether need to call NEW-PAGE at the beginning.

Hope this helps.

Happy ABAP-ing =D

Answers (5)

Answers (5)

Former Member
0 Kudos

tks

Former Member
0 Kudos

Thanks for the reply Netaji..

The code you have provided is for a z program. But z program is not used here. I need to attach the script to a standard program RFFOUS_C. We need to include the code in the script itself.

Please provide me the way of including the code as it is a standard program and we cannot modify it. Everything needs to be done in the script itself.

Thanks,

Priya

Former Member
0 Kudos

hi,

Do this

in print program

call function 'OPEN_FORM'

sort itab by bukrs.

loop at itab.

at new bukrs.

if itab-bukrs = 1.

call function 'START_FORM'

Exporting

Page = 'ONE'.

elseif itab-bukrs = 2

call function 'START_FORM'

Exporting

Page = 'TWO'

endif.

endat.

-


-


-


at end of bukrs.

Call function 'END_FORM'.

endat.

endloop.

Call function 'CLOSE_FORM'.

Thanks,

Nethaji.

Former Member
0 Kudos

Thanks a lot Adric.. My requirement is like there will be 5 countries which will make payments through cheques and those cheques are pre- printed ones.

The form which i am going to develop is attached to the standard program rffous_c.

The form should have 5 pages differently and depending on the company code, the pages should be called. Please suggest me the way with example code and the procedure.

Former Member
0 Kudos

I have done the similar thing in COBRA letters. Because the standard program only call a single form and the users wanted it to print all the letters in one place.

The solution I used was to combine all the forms in one and use subroutine in my own z program to retrieve missing values. It's quite troublesome, but it works as users' requirements.

You could do the similar. Try have 5 variables in your form. These 5 variables will decide which page to display next. It might have problem with the first page. It might result extra blank first page because of this logic.

Hope this helps. =D

Former Member
0 Kudos

Hi Adric,

Thank s for the solution.

Can you please gimme the sample code of urs and plz elaborate it., I am very much new to the scripts and this is my first object.. Please explain it in detail.

If you have used ur own program a Z one, how could you call the program along with the standard program? Please provide it in detail

Regards,

Priya

Former Member
0 Kudos

This approach to make call from SAPscript. Its concept is similar to make call to a subroutine in another program. I would presume you understand how to use USING and CHANGING parameter. 😃

-


SAPscript -


/: Perform get_date in program z_at_date

/: using &p_year&

/: changing &new_date&

/: endperform.

-


program z_at_date -


form get_date TABLES rec_in STRUCTURE itcsy

rec_out STRUCTURE itcsy..

DATA:

v_year type char10.

  • sap script and subroutine uses itcsy structure to transmit parameters

  • first parameter is incoming while second parameter is out going

  • their function is like an internal table with header line

  • all data types between SAPscript and subroutine are string.

  • so, you might need additional conversion.

  • read incoming parameter with exact name from SAPscript

READ TABLE rec_in WITH KEY name = 'P_YEAR'.

IF sy-subrc EQ 0.

v_year = rec_in-value.

ENDIF.

  • to return value, use the exact name on the second structure

CONCATENATE v_year v_year INTO v_year.

READ TABLE rec_out WITH KEY name = 'NEW_DATE'.

IF sy-subrc EQ 0.

rec_out-value = v_year.

MODIFY rec_out TRANSPORTING value WHERE name = 'NEW_DATE'.

ENDIF.

endform.

-


Hope this helps 😃

Former Member
0 Kudos

Thanks a lot Adric. Sorry i had no time to check it . I will definitely try it out and let u know.

U have really helped me out.

Former Member
0 Kudos

This might contribute to the workaround.

Incidentally, another method of redirecting output to a page not mapped within the standard output flow is the 'NEW-PAGE' command which may be issued within the SAPscript form itself. Its basic syntax is NEW-PAGE xxx, where xxx is an optional parameter. This will force a page break and direct all subsequent output to page xxx. There are some important restrictions on use of this command. For instance, it can be used only within a MAIN window and it triggers immediate output of all remaining windows on the current page. You can find more information on this command in the SAP help portal. Visit http://help.sap.com. Navigate to section BC-SRV-SCR (Basis Services - SAPscript) and click on the subsection entitled "Style and Form Maintenance". Drill down further into "SAPscript Control Commands" and choose "Explicit Page Break: NEW-PAGE".

Source: http://expertanswercenter.techtarget.com/eac/knowledgebaseAnswer/0,295199,sid63_gci983455,00.html