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: 
Read only

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

chetan_shah9
Explorer
0 Likes
3,127

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
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,655

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

9 REPLIES 9
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,656

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

Read only

2,655

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.

Read only

0 Likes
2,655

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

Read only

matt
Active Contributor
2,655

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.

Read only

0 Likes
2,655

Thanks for the explanation Matt.

Read only

0 Likes
2,655

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.

Read only

matt
Active Contributor
0 Likes
2,655

Data Transfer Process.

Read only

kiran_k8
Active Contributor
0 Likes
2,655

Chetan,

May I know the objective of this exercise ?

Just curious 🙂

K.Kiran.

Read only

chetan_shah9
Explorer
0 Likes
2,655

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