Google Search - Blog...........

ABAP - Program For Finding Hardcoded Text.

*---------------------------------------------------------------------*
* Report Name: Z_TEST_HARD_CODING
*
* Desc : Detecting hard coding in Programs
* Author : Arun Nair
*---------------------------------------------------------------------*

REPORT z_test_hard_coding 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 char72,
END OF ty_zprog.

TYPES: BEGIN OF ty_zprogdet,
prog TYPE programm,
linenr TYPE i,
line TYPE char72,
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.

No comments:

Post a Comment