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: 

calling perform from another Program

aboooood
Participant
0 Kudos

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.
1 ACCEPTED SOLUTION

abo
Active Contributor
PERFORM mk_03
vs
FORM call_mk03
25 REPLIES 25

abo
Active Contributor
PERFORM mk_03
vs
FORM call_mk03

0 Kudos

oh Im so sorry I feel really bad for this bad mistake :((

thx

abo
Active Contributor

no worries, I've lost count of the times I couldn't see this kind of mistakes in my code 🙂

abo
Active Contributor

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.

0 Kudos

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?

abo
Active Contributor

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

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 !

abo
Active Contributor

"hallo zusammen" does not neatly translate into English although I feel it should 😄

former_member751463
Participant
0 Kudos

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.

aboooood
Participant

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

matt
Active Contributor

c5e08e0478aa4727abc4482f5be390b2

Sure it does. "Hi everyone".

I prefer the dialect. "Hoi zsamme".

matt
Active Contributor

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.

Ryan-Crosby
Active Contributor

matthew.billingham - Haha @ the weeping!! A combination of BDC and 90s programming is bound to be a robust solution 😛

abo
Active Contributor
0 Kudos
matthew.billingham

surely not with "together" 🙂

hardyp180
Active Contributor

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.

Ryan-Crosby
Active Contributor
bfeeb8ed7fa64a7d95efc21f74a8c135

"That's the way I've always done it" - a guarantee of never improving anything...

aboooood
Participant
0 Kudos

matthew.billingham so what is the modern programming?

Sandra_Rossi
Active Contributor
matthew.billingham

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.

aboooood
Participant

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 😞

matt
Active Contributor

c5e08e0478aa4727abc4482f5be390b2Even "ciao zsamme".

Could be worse. "Sali, alli ziet".

aboooood
Participant

matthew.billingham it's evolving backwards XD

i should ask in German next time 😞

matt
Active Contributor

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.

aboooood
Participant

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!

abo
Active Contributor
0 Kudos
matthew.billingham

wo wohnst du gerade? Das klingt... echt komisch 🙂

aboooood

kein Problem 🙂

matt
Active Contributor

c5e08e0478aa4727abc4482f5be390b2

Switzerland!

aboooood You're welcome. It's always nice when people want to improve the way they code! 😀