2022 Jul 19 9:29 AM
Hallo together, i have to call a Form from anotehr Report but Im having a Problem it wonts work. there is no syntax error.
*Programm A
READ TABLE gt_out ASSIGNING FIELD-SYMBOL(<fs_gtout>) INDEX row.
IF sy-subrc = 0 .
*Für die EBELN wird diese FUBA aufgerufen um den richtigen EBELN mit den richtigen position angezeigt wird
CASE column.
WHEN 'EBELN'.
CHECK <fs_gtout>-ebeln IS NOT INITIAL AND <fs_gtout>-ebelp IS NOT INITIAL.
CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
EXPORTING
i_ebeln = <fs_gtout>-ebeln
i_ebelp = <fs_gtout>-ebelp
i_display_only = abap_true
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE sy-msgty.
ENDIF.
WHEN 'MATNR'.
CHECK <fs_gtout>-matnr IS NOT INITIAL.
SET PARAMETER ID 'MAT' FIELD <fs_gtout>-matnr.
CALL TRANSACTION 'ZDISPO' AND SKIP FIRST SCREEN.
WHEN 'LIFNR'.
CHECK <fs_gtout>-lifnr IS NOT INITIAL.
SET PARAMETER ID 'LRE' FIELD <fs_gtout>-lifnr.
PERFORM mk_03 IN PROGRAM b USING <fs_gtout>-lifnr.
ENDCASE.
ENDIF.
*Program b
FORM call_mk03 USING l_lifnr.
DATA BEGIN OF bdcdata OCCURS 100.
INCLUDE STRUCTURE bdcdata.
DATA END OF bdcdata.
DATA BEGIN OF itab OCCURS 10.
INCLUDE STRUCTURE bdcmsgcoll.
DATA END OF itab.
DATA: c_temp(10) TYPE c.
SELECT SINGLE * FROM wyt3 WHERE lifnr = l_lifnr
AND ekorg = '1000'.
IF sy-subrc <> 0.
* set parameter id 'LIF' field l_lifnr.
* set parameter id 'EKO' field '1000'.
** set parameter id '
* call transaction 'MK03' and skip first screen.
* TODO Fehlermeldung
SELECT SINGLE * FROM lfa1 WHERE lifnr = l_lifnr
AND ktokk = 'REPA'.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDIF.
bdcdata-program = 'SAPMF02K'.
bdcdata-dynpro = '0108'.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
CLEAR bdcdata.
bdcdata-fnam = 'BDC_OKCODE'.
bdcdata-fval = '/00'.
APPEND bdcdata.
bdcdata-fnam = 'BDC_CURSOR'.
bdcdata-fval = 'RF02K-LIFNR'.
APPEND bdcdata.
bdcdata-fnam = 'RF02K-LIFNR'.
bdcdata-fval = l_lifnr.
APPEND bdcdata.
bdcdata-fnam = 'RF02K-EKORG'.
bdcdata-fval = '1000'.
APPEND bdcdata.
bdcdata-fnam = 'RF02K-D0110'.
bdcdata-fval = 'X'.
APPEND bdcdata.
bdcdata-fnam = 'RF02K-D0120'.
bdcdata-fval = ''.
APPEND bdcdata.
bdcdata-fnam = 'RF02K-D0130'.
bdcdata-fval = ''.
APPEND bdcdata.
bdcdata-fnam = 'WRF02K-D0380'.
bdcdata-fval = 'X'.
APPEND bdcdata.
bdcdata-fnam = 'RF02K-D0310'.
bdcdata-fval = 'X'.
APPEND bdcdata.
bdcdata-fnam = 'WRF02K-D0320'.
bdcdata-fval = 'X'.
APPEND bdcdata.
* Keine Fehler => Transaktion kann ausgeführt werden
CALL TRANSACTION 'MK03' USING bdcdata MODE 'E' MESSAGES INTO itab.
2022 Jul 19 9:56 AM
2022 Jul 19 9:56 AM
2022 Jul 19 11:01 AM
oh Im so sorry I feel really bad for this bad mistake :((
thx
2022 Jul 19 11:10 AM
no worries, I've lost count of the times I couldn't see this kind of mistakes in my code 🙂
2022 Jul 19 12:11 PM
PS: although both programs can be activated, you should see a dump when the calling program actually attempts to run the PERFORM IN PROGRAM statement. To avoid it, if necessary, you may use the "IF FOUND" extension.
2022 Jul 19 2:55 PM
thank u sir! i have one last quistion:
PERFORM call_mk03 IN PROGRAM bCHANGING <fs_gtout>-lifnr IF FOUND.
PERFORM call_mk03 IN PROGRAM b USING <fs_gtout>-lifnr IF FOUND.
whats the different between using and changing?
2022 Jul 19 3:33 PM
Careful, do not abuse "IF FOUND": it is not intended as a catch-all, rather when you're deliberately planning a later development.
changing vs using is the same as with a normal (i.e., not "in program") PERFORM call
2022 Jul 19 3:42 PM
i thought IF FOUND is a must. i took it out of my Programm i will just use it fpr later planning develpment.
thank u again !
2022 Jul 19 9:57 AM
"hallo zusammen" does not neatly translate into English although I feel it should 😄
2022 Jul 19 10:04 AM
Hi Abood,
We need more information to provide any feedback. Its better if you can debug the program and see where the error is. What is the output of the program.Check if any data is selected or not. What is the sy-subrc value after call transaction. You need to check these things.
Thanks,
Aditya.
2022 Jul 19 10:56 AM
The "Hallo" was very bad u r right but the together should be acceptable somehow XD
lerning English from video games was not the best choice i guess XD
2022 Jul 19 7:23 PM
c5e08e0478aa4727abc4482f5be390b2
Sure it does. "Hi everyone".
I prefer the dialect. "Hoi zsamme".
2022 Jul 19 7:27 PM
PERFORM mk_03 IN PROGRAM b USING <fs_gtout>-lifnr.
is very bad programming. Do it differently. Seriously. This is 1990s programming.
@ sandra.rossi bfeeb8ed7fa64a7d95efc21f74a8c135
I could weep.
2022 Jul 19 7:39 PM
matthew.billingham - Haha @ the weeping!! A combination of BDC and 90s programming is bound to be a robust solution 😛
2022 Jul 19 9:33 PM
2022 Jul 20 12:32 AM
Oh dear. That is all I can say.
Remote PERFORMS are an abomination. Even back in 1997 there were far, far, better ways of doing things. Then, as now, you should find a way to encapsulate re-usable code.
Why do people still program like this in 2022? I can only presume that is the way they were taught, and that is the way they will teach their successor to do things. Nobody ever questioning anything, no-one ever thinking there might be a better way.
2022 Jul 20 1:25 AM
"That's the way I've always done it" - a guarantee of never improving anything...
2022 Jul 20 7:19 AM
2022 Jul 20 7:33 AM
Please don't get me in this kind of good/evil trap 😄
Of course, in my experience, I found out that ABAP Objects was much more maintainable than the old subroutines, provided that you code it well. But I also understand that people are in their learning curve (or don't want to learn), so I don't blame them. By the way, I often use PERFORM when I need to fix bugs of old-fashioned programs, but trying to add ABAP Objects as much as I can, if it helps in the code, so that to leave the program in better shape.
2022 Jul 20 7:41 AM
sandra.rossi i try to use everything i learned and yes i need to focus more on abap oo but i thought working with PERFORM isnt that bad 😞
2022 Jul 20 7:46 AM
c5e08e0478aa4727abc4482f5be390b2Even "ciao zsamme".
Could be worse. "Sali, alli ziet".
2022 Jul 20 7:50 AM
matthew.billingham it's evolving backwards XD
i should ask in German next time 😞
2022 Jul 20 7:53 AM
aboooood
Modern programming in the context of ABAP is two things.
1. Not using, in new programs, parts of the language that are listed as obsolete in the ABAP documentation. Occasionally you'll meet these things in old programs, so you may need to know about them. When you do, where possible, fix them.
2. Use classes and methods. Preferably with interfaces, factory classes and ABAP unit tests. It takes time to become proficient in these things, but this is where a new programmer should concentrate their time, in my view.
PERFORM ... IN PROGRAM is even used in some of my programs where I call a form in a SAP program and there's no other interface. But it is really to be avoided wherever possible.
I took over a code base a few years ago. One of the first things I did was change all the forms (and macros*) into methods.
* Yes... I shudder at the thought.
2022 Jul 20 8:00 AM
well, Im a fan of classes and methods but i thought even a perform is a old still a good choice. now with ur help guys i should take more time for classes and methods. thank you guys again!
2022 Jul 20 8:17 AM
wo wohnst du gerade? Das klingt... echt komisch 🙂
aboooood
kein Problem 🙂
2022 Jul 20 10:55 AM
c5e08e0478aa4727abc4482f5be390b2
Switzerland!
aboooood You're welcome. It's always nice when people want to improve the way they code! 😀