Application Development and Automation 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: 

Set a Break-point at particular word in Z program programatically.

chetan_shah9
Explorer
0 Kudos
1,275

Hello Everyone,

I have a requirement to set break-point in zprogram at a particular FM or keyword (say "REUSE_ALV_GRID_DISPLAY" in "ZANY_PROGRAM" program) programatically.

I am aware of below code to set breakpoint in any program at particular line number.

  wa_breakpoints-program = sy-repid.
  wa_breakpoints-line    = 3.
  APPEND wa_breakpoints TO breakpoints.
  CALL METHOD cl_abap_debugger=>save_breakpoints
    EXPORTING
      main_program = sy-repid     "Program name
      breakpoints  = breakpoints.

However cannot figure out a way to get line number from the keyword.

Any help will be appreciated. Thank you

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos
803

You may use the statement READ REPORT to read the source code.

9 REPLIES 9

Sandra_Rossi
Active Contributor
0 Kudos
804

You may use the statement READ REPORT to read the source code.

803

Thank you Sandra. I created below program using Read Report to get the line number of particular string. Hope it helps someone.

DATA:
  template TYPE          c LENGTH 30,
  source   TYPE TABLE OF string,
  wa       TYPE          source.

template = 'ZRLB_INVOICE'.

READ REPORT template INTO source.
IF sy-subrc <> 0.
  RETURN.
ELSE.
  LOOP AT source INTO wa WHERE table_line CS 'SSF_FUNCTION_MODULE_NAME'.
    WRITE: sy-tabix.
  ENDLOOP.
ENDIF.

0 Kudos
803

Why would you need to do this ? Perhaps I am thinking too simplistically here, but you can set break points from other GUI sessions at statemments, procedures, methods and functions, you can set watch points on variable values etc etc. Why would you programatically want to set a break-point ?

Rich

matt
Active Contributor
803

In BW you'll see code like

IF certain_flag EQ abap_true.
BREAK-POINT.
ENDIF.

This is used in some data processing, where you tell the DTP that you want to debug before the start routine begins, for example. The start routine is held in a locally generated program, so isn't readily accessible to place the break-point. (Actually, it is, you just go to the DTP and choose "display generate program", but that's probably too technical for most BW people. 😉 ).

I imagine the OP is wanting to do something similar.

0 Kudos
803

Thanks for the explanation Matt.

0 Kudos
803

Matt,

Now I understood the funda behind those break-points which I got to see while developing a few routines in BW.Thanks for the info.Would you also let us know what is DTP (InfoObjects,InforSources....?)

K.Kiran.

matt
Active Contributor
0 Kudos
803

Data Transfer Process.

kiran_k8
Active Contributor
0 Kudos
803

Chetan,

May I know the objective of this exercise ?

Just curious 🙂

K.Kiran.

chetan_shah9
Explorer
0 Kudos
803

Hello Kiran,

We have multiple print program each triggering multiple smart form in our project. It becomes extremely time consuming at times to find the correct print program triggering the smart form. The above logic might help to set breakpoints in all print program's 'SSF_FUNCTION_MODULE_NAME' thus saving time finding the right program.

Thanks and Regards,

Chetan Shah