2009 May 07 2:25 PM
I am rather new to ABAP OO. I'm trying to re-write a traditional ABAP program using ABAP OO. I ran across a PERFORM routine which I'm not sure if I can duplicate how it works using something similar with a METHOD.
Here is the PERFORM routine which passes only one variable, but the routine is performed multiple times for each of the values after the 'USING' command:
PERFORM init_pids USING: 'PBR', 'PBS', 'PRG', 'PKR', 'KOS'.
The only way I know of how to achieve this same thing with ABAP OO is like this, which you can see takes more coding:
CALL METHOD lcl_zhr10014=>init_pids( 'PBR' ).
CALL METHOD lcl_zhr10014=>init_pids( 'PBS' ).
CALL METHOD lcl_zhr10014=>init_pids( 'PRG' ).
CALL METHOD lcl_zhr10014=>init_pids( 'PKR' ).
CALL METHOD lcl_zhr10014=>init_pids( 'KOS' ).
Is there another more efficient way?
2009 May 07 3:04 PM
PERFORM init_pids USING: 'PBR', 'PBS', 'PRG', 'PKR', 'KOS'.
As you have chained the PERFORM statement, you can also chain this CALL METHOD statement.
CALL METHOD:
lcl_zhr10014=>init_pids( 'PBR' ),
lcl_zhr10014=>init_pids( 'PBS' ),
lcl_zhr10014=>init_pids( 'PRG' ),
lcl_zhr10014=>init_pids( 'PKR' ),
lcl_zhr10014=>init_pids( 'KOS' ).
You can also try to create MACRO and use it.
If you are using the Global class than create a macro in the MACRO section (button on the application toolbar) and use it here instead of calling the method.
Regards,
Naimesh Patel
I am rather new to ABAP OO. I'm trying to re-write a traditional ABAP program using ABAP OO. I ran across a PERFORM routine which I'm not sure if I can duplicate how it works using something similar with a METHOD.
Here is the PERFORM routine which passes only one variable, but the routine is performed multiple times for each of the values after the 'USING' command:
PERFORM init_pids USING: 'PBR', 'PBS', 'PRG', 'PKR', 'KOS'.
The only way I know of how to achieve this same thing with ABAP OO is like this, which you can see takes more coding:
CALL METHOD lcl_zhr10014=>init_pids( 'PBR' ).
CALL METHOD lcl_zhr10014=>init_pids( 'PBS' ).
CALL METHOD lcl_zhr10014=>init_pids( 'PRG' ).
CALL METHOD lcl_zhr10014=>init_pids( 'PKR' ).
CALL METHOD lcl_zhr10014=>init_pids( 'KOS' ).
Is there another more efficient way?
2009 May 07 2:48 PM
Hi Kenneth,
Here is what i think:
PERFORM init_pids USING: 'PBR', 'PBS', 'PRG', 'PKR', 'KOS'.
*Technically it be will execute as, Its JUST more readable
PERFORM init_pids USING 'PBR'.
PERFORM init_pids USING 'PBS'.
PERFORM init_pids USING 'PRG'.
PERFORM init_pids USING 'PKR'.
PERFORM init_pids USING 'KOS'.
* As far as OO is concerned you have written as
CALL METHOD lcl_zhr10014=>init_pids( 'PBR' ).
CALL METHOD lcl_zhr10014=>init_pids( 'PBS' ).
CALL METHOD lcl_zhr10014=>init_pids( 'PRG' ).
CALL METHOD lcl_zhr10014=>init_pids( 'PKR' ).
CALL METHOD lcl_zhr10014=>init_pids( 'KOS' ).
So both ways I will say are same. In OO there is no other way to write it.
If at all you need to change it you can WRITE CALL METHOD in LOOP and change the parameter value runtime, but this doesn't add any value.
Regards
Shital
2009 May 07 3:04 PM
PERFORM init_pids USING: 'PBR', 'PBS', 'PRG', 'PKR', 'KOS'.
As you have chained the PERFORM statement, you can also chain this CALL METHOD statement.
CALL METHOD:
lcl_zhr10014=>init_pids( 'PBR' ),
lcl_zhr10014=>init_pids( 'PBS' ),
lcl_zhr10014=>init_pids( 'PRG' ),
lcl_zhr10014=>init_pids( 'PKR' ),
lcl_zhr10014=>init_pids( 'KOS' ).
You can also try to create MACRO and use it.
If you are using the Global class than create a macro in the MACRO section (button on the application toolbar) and use it here instead of calling the method.
Regards,
Naimesh Patel
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |