0

I read something about the ok-code but I cant really understand how it works and how I have to implement it.

I tried implementing a MODULE in the PAI for my Buttons but they are not working either.

MODULE test INPUT.
  case sy-ucomm.
    when 'BTN_01'.
      call screen 0.
  endcase.
ENDMODULE.

Thanks!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • 1
    More details please. How did you setup the screen, what status do you use, what does the corresponding PBO look like? – vwegert Nov 07 '16 at 09:28
  • Ich habe zuerst ein Programm erstellt und in diesem die Dynpro 9000 erzeugt/aufgerufen. In der Dynpro habe ich eine Tabelle die in der PBO gefüllt wird. Sonst nichts. Ich arbeite erste seit 4-5 Tagen mit Abap und steige da leider noch nicht so durch. –  Nov 07 '16 at 09:37
  • Let's keep this in English, please. I'd strongly suggest you get the appropriate training, although it will cost your employer a bit. BC410 would be the course you're aiming for - [here](https://training.sap.com/de/de/curriculum/nw_prodia_de-dialogprogrammierung-de) is a curriculum. Other than that, check the examples in transaction ABAPDOCU. – vwegert Nov 07 '16 at 09:41
  • Okay, i'll do that. Thanks for your help! –  Nov 07 '16 at 09:46
  • I understand that this might not seem to be a satisfactory answer, but you essentially need intensive training and guidance, rather than the short Q&A-style format of SO. – vwegert Nov 07 '16 at 09:47
  • That's right. But still thanks for your answer. i appreciate it. –  Nov 07 '16 at 09:55

2 Answers2

1

There are not enough details to give a real answer, so my answer is kind of a guess.

In your title you mention a "Exitbutton". Has the button the function type "E"?

If yes, then maybe you better use

MODULE ... AT EXIT-COMMAND.

Another hint: To see what happens, you may enter /h in the OK-code field (activate debugging, 'Hoppelmodus' :) ). Then push your button and hopefully you can see step by step what happens.

knut
  • 27,320
  • 6
  • 84
  • 112
  • Great! Didn't know i could use a debugger in ABAP. This will help me alot. Thanks! :) –  Nov 07 '16 at 11:27
  • When you don't know the debbuger: A better way to activate the debugger is in SE38 (Code Editor). You can set a breakpoint at selected code locations. The Debugger starts the debugging, when your programm executes this place (I didn't mention it in the answer. If you have the impression your code is not executed, then it makes no sense to set the breakpoint there). – knut Nov 07 '16 at 11:33
  • So, the debugger works the same way like in visualstudio, right? –  Nov 07 '16 at 11:35
  • I guess yes. (I don't know visualstudio). You can set break point, you can set watch points (stop if a variable fulfill a special condition or if it changes), you can set break points on statements (what I like very much: Stop if a special message is given. So I can stop, where I get a specific error message). Inside the debugger you can continue stepwise, next function... If you have the rights, you can also change variables, – knut Nov 07 '16 at 11:39
  • Okay, so it works the same way ;) Thank you very much! –  Nov 07 '16 at 11:42
0

SOLVED

MODULE status_9000 OUTPUT.
  SET PF-STATUS 'STATUS9000'.
  SET TITLEBAR 'TITLE9000'.
ENDMODULE.

I had to create a PF-STATUS for my screen (i named it 'STATUS9000'). Functionbuttons-> Symbols-> Set Exit-Button FNCT-CODE EXIT

MODULE user_command_9100 INPUT.
  ok_code = sy-ucomm.
CASE ok_code.
*now if you click the red exit-button (which we gave a fnct-code[exit]) the ok_code has 'EXIT' as his value.
  WHEN 'BACK'.
    LEAVE TO SCREEN 9000.
  WHEN 'EXIT'.
    LEAVE PROGRAM.
  WHEN OTHERS.
ENDCASE.
ENDMODULE.

ok-code = 'EXIT' after we pressed the exit-button, so we are going to leave the program.