ABAP Program to Track ‘Hard Coding’ in Programs

0
141

Hard-coding has been very much an integral part of ABAP coding. Many a times lot of text is hard coded in programs right from select statements to selection screen parameters to more complicated case statements and other conditional statements. The more deadlier hard coding is found in user exits or BTE’s.

Typically during roll-outs the existing programs may have to be modified to include the new company code etc. However it might take lot of debugging to figure out what went wrong if we missed a small exit where very important code was written.

Program Initial Screen
Program Initial Screen

The below mentioned program can be run before roll-outs to determine if any hard coding is present. The hard coding can be from company code to plant to form names or report names. The output of this report will help you to estimate roughly in which programs or exits changes might have to be done. This report will be also useful for production support issues arising after go-live.

Program Source

REPORT  ZTST_TRACK NO STANDARD PAGE HEADING
LINE-SIZE 180
LINE-COUNT 45.
*———————————————————————*
* DATA DECLARATION *
*———————————————————————*
TYPES: BEGIN OF ty_ztab,
prog TYPE programm,
END OF ty_ztab.
TYPES: BEGIN OF ty_zprog,
line TYPE char200,
END OF ty_zprog.
TYPES: BEGIN OF ty_zprogdet,
prog TYPE programm,
linenr TYPE i,
line TYPE char200,
END OF ty_zprogdet.
DATA: i_prog TYPE STANDARD TABLE OF ty_ztab,
wa_prog TYPE ty_ztab.
DATA: i_zprog TYPE STANDARD TABLE OF ty_zprog,
wa_zprog TYPE ty_zprog.
DATA: i_zprogdet TYPE STANDARD TABLE OF ty_zprogdet,
wa_zprogdet TYPE ty_zprogdet.
PARAMETERS: p_hard TYPE char25 OBLIGATORY.
PARAMETERS: p_chk TYPE char25 OBLIGATORY DEFAULT ‘Z*’.
PARAMETERS: p_full RADIOBUTTON GROUP g1,
p_nam RADIOBUTTON GROUP g1.
*———————————————————————*
* START OF SELECTION *
*———————————————————————*
START-OF-SELECTION.
*– Replace * by %
REPLACE ALL OCCURRENCES OF ‘*’ IN p_chk WITH ‘%’.
*–get the list of programs
SELECT prog FROM d010sinf
INTO TABLE i_prog
WHERE prog LIKE p_chk.
IF sy-subrc = 0.
LOOP AT i_prog INTO wa_prog.
READ REPORT wa_prog-prog INTO i_zprog.
IF sy-subrc = 0.
LOOP AT i_zprog INTO wa_zprog.
IF wa_zprog-line CS p_hard.
wa_zprogdet-prog = wa_prog-prog.
wa_zprogdet-line = wa_zprog-line.
wa_zprogdet-linenr = sy-tabix.
APPEND wa_zprogdet TO i_zprogdet.
CLEAR wa_zprogdet.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
ELSE.
*– Message – No entries found
ENDIF.
IF i_zprogdet IS INITIAL.
*– Message – No entries found
ENDIF.
*———————————————————————*
* END OF SELECTION *
*———————————————————————*
END-OF-SELECTION.
*– Display report
LOOP AT i_zprogdet INTO wa_zprogdet.
AT NEW prog.
IF p_full EQ ‘X’.
SKIP.
WRITE: / wa_zprogdet-prog COLOR 4.
SKIP.
ELSE.
WRITE: / wa_zprogdet-prog COLOR 4.
ENDIF.
ENDAT.
IF p_full EQ ‘X’.
WRITE: / wa_zprogdet-prog,
‘LINE Nr:’,
wa_zprogdet-linenr,
wa_zprogdet-line COLOR 2.
ENDIF.
ENDLOOP.


Output of the report is as under:

Report Output
Report Output

*source= Arun Nair

LEAVE A REPLY