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: 

Please:How to repeat the return values multiple times in sapscript

Former Member
0 Kudos
721

Currently my subroutine is returning a value called TOQBSSHB single time and i am working with standard layout called RFFOUS_C.Please can anybody tell me if i want to show multiple times TOQBSSHB for different values of VBLNR .Is it possible if it is what are changes i should make on layout and subroutine.

PERFORM EXTRACT IN PROGRAM Y_MIT_TEST2

USING &REGUH-VBLNR&

USING &REGUH-NAME1&

CHANGING&TOTQBSHB&

ENDPERFORM

FORM EXTRACT TABLES IN_PAR STRUCTURE ITCSY OUT_PAR STRUCTURE ITCSY.

TABLES : REGUP,BSEG,REGUH,REGUD.

DATA : BILL_NO LIKE REGUH-VBLNR.

DATA : ITAB LIKE REGUP OCCURS 0 WITH HEADER LINE.

DATA : JTAB LIKE REGUP OCCURS 0 WITH HEADER LINE.

DATA : BELNR1 LIKE ITAB-BELNR.

DATA : QBSHB1 LIKE REGUD-SWNES.

DATA : QBSHB2 LIKE REGUD-SWNES.

DATA : TOTOQBSHB LIKE REGUD-SWNES.

READ TABLE IN_PAR WITH KEY NAME = 'REGUH-VBLNR'.

IF SY-SUBRC = 0.

BILL_NO = IN_PAR-VALUE.

ENDIF.

SELECT * FROM REGUP INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE VBLNR

= BILL_NO.

READ TABLE ITAB INDEX 1.

IF SY-SUBRC = 0.

MOVE ITAB-QBSHB TO QBSHB1.

MOVE ITAB-BELNR TO BELNR1.

ENDIF.

SELECT * FROM BSEG INTO CORRESPONDING FIELDS OF TABLE JTAB WHERE BELNR

= BELNR1.

LOOP AT JTAB.

READ TABLE JTAB INDEX SY-TABIX.

IF SY-SUBRC = 0.

QBSHB2 = QBSHB2 + JTAB-QBSHB.

ENDIF.

ENDLOOP.

TOTOQBSHB = QBSHB1 + QBSHB2.

READ TABLE OUT_PAR WITH KEY NAME = 'TOTQBSHB'.

IF SY-SUBRC = 0.

MOVE TOTOQBSHB TO OUT_PAR-VALUE.

MODIFY OUT_PAR INDEX SY-TABIX.

ENDIF.

ENDFORM.

1 ACCEPTED SOLUTION

former_member182371
Active Contributor
0 Kudos
262

Hi Mave,

one possible solution could be:

1.- copy RFFOUS_C to ZRFFOUS_C

2.- Assign this new print program to the corresponding report or sapscript.

3.- In the flow of the ZRFFOUS_C do your SELECT statements.

4.- and finally add something like:

LOOP AT JTAB.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'YOURDATAELEMENT'

WINDOW = 'MAIN'

EXCEPTIONS

OTHERS = 1.

ENDLOOP.

So as you can see you´d need to create a new data element in the sapscript an a new variable

(e.g. &TOTQBSHB&)

Best regards.

17 REPLIES 17

former_member182371
Active Contributor
0 Kudos
263

Hi Mave,

one possible solution could be:

1.- copy RFFOUS_C to ZRFFOUS_C

2.- Assign this new print program to the corresponding report or sapscript.

3.- In the flow of the ZRFFOUS_C do your SELECT statements.

4.- and finally add something like:

LOOP AT JTAB.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'YOURDATAELEMENT'

WINDOW = 'MAIN'

EXCEPTIONS

OTHERS = 1.

ENDLOOP.

So as you can see you´d need to create a new data element in the sapscript an a new variable

(e.g. &TOTQBSHB&)

Best regards.

0 Kudos
262

Hi, calsadillo

I made a new copy of RFFOUS_ C as YRFFOUS_ C but it is not compling showing errors.All the 'Z' fields are showing errors while compling.

Thanks and regards.

Mave

0 Kudos
262

Hi Calsadillo

How can i see the top include of RFFous_c program.

Thanks and regards

Mave

0 Kudos
262

The top include is RFFORI00, but if you have copied only main program RFFOUS_C, you can define your new variable in it without to change top include

Message was edited by: max bianchi

0 Kudos
262

Hi Max Bianchi and Calsadillo,

Please tell me the path to see the top include .

I mean how did you fingd the top include for the program.

Should i copy the top include for RFFOUS_C program and assign it to the YRFFOUS_C program .

IS IT POSSIBLE ?

Thanks and Regards

Mave

0 Kudos
262

The TOP include of a program is usually the include where data and variables are defined. So you should find the include with the definitions. It can be more top include than one, but in your program I seem there is onlu one: look at thies piece of code of RFFOUS_C

  • tables / fields / field-groups / at selection-screen *

----


INCLUDE RFFORI00.

When you copy a standard program, you should copy only includes you need.

So:

- Copy only (not include) RFFOUS_C in YRFFOUS_C,

- find the point of program where you should insert

your code, if the point isn't writed in main program

(YRFFOUS_C), but in a include, copy it and write your

code in it. Of course you have to replace the call of

that include.

So: you can wirte your definination in YRFFOUS_C without change top include, for example:

........

INCLUDE RFFORI00.

DATA: MY_DATA....

or you can create a new top include and insert your definations in it

........

INCLUDE RFFORI00.

INCLUDE ZMY_INCLUDE.

or you can copy top include and insert your definitations in it:

........

*INCLUDE RFFORI00.

INCLUDE ZRFFORI00.

0 Kudos
262

Dear Max,

You seems to me a great programmer .

Your answer till now for me the most satisfying.

May i request you to please give me your contact details.

Thanks and regards

Mave

0 Kudos
262

No problem: max_abap4@yahoo.it

0 Kudos
262

Dear max,

If you carefully read what ever you have written a contradiction can be observed.

You said earlier how to copy a standard program is just to copy the includes only.

latter you have written copy with out includes.

I mean i did not get you.

I am sorry for that.

Could you please tell me breifly how to create a Copy of the standard program RFFous_c to zrffous_c.

Thanks and regards

Mave.

0 Kudos
262

hello max,

Can you please tell me how to copy the standard rffous_c program into zrffous_c program.

i am facing problems.

regards

Mave

0 Kudos
262

I said :

- A) you should copy the main program without to copy

includes, so when the systems ask you which objects

you want to copy: check all excluding INCLUDES.

So you'll have a new program which uses the same includes of the standard program.

- B) in your z-program you find the point where you should insert your code: you'll have two cases:

- you should insert code in a point that is writen in z-program;

- you should insert code in a point (for example a form) that isn't write in z-program, but in a standard include your z-program use.

In first case you only write your code, in second one before you should copy the include, than insert it in your z-program and so insert your code in the include.

For example:

- A) Copy RFFOUS_C in ZRFFOUS_C

- B) I should change the code of routine

SCHECKDATEN_EINGABE, it's defined in RFFORI01, so I copy it in ZRFFORI01, insert my code in it.

- C) found where my z-program call include RFFORI01:

----


  • subroutines for check print and prenumbered checks *

----


INCLUDE RFFORI01.

now replace this with the call to my new include:

  • INCLUDE RFFORI01.

INCLUDE ZRFFORI01.

If you do in this way you copy only includes where you should change the code.

Message was edited by: max bianchi

Message was edited by: max bianchi

former_member182371
Active Contributor
0 Kudos
262

Hi Mave,

program RFFOUS_C has many includes (that have to be copied as well if you need them).

Make sure you copy them as well.

Best regards.

0 Kudos
262

Hi, calsadillo

For field ZW_XVORL the compliation is showing error.

I have changed all the includes in the program mentioned.

Thanks and regards

Mave

former_member182371
Active Contributor
0 Kudos
262

Hi Mave,

What does the error say?

Regards.

0 Kudos
262

Hi calsadillo,

Basically the field is for the selection screen and ZWX_vorl is one of the selection screen field .

The error is showing the field is not defined in one of the table and data statement.

Thanks and Regards

Mave

former_member182371
Active Contributor
0 Kudos
262

Hi Mave,

i guess the selection screen of zrffous_c shouldbe defined in top include.

Try to define the field in this top include.

Regards.

0 Kudos
262

hi casadillo,

how can i go to the top include?

Thanks and regards

Mave