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

HardCoding - How to find out

Former Member
0 Likes
2,406

Hi Experts,

According to my rek, I need to find out is there any thing hardcoded in the system for the currency.

Is there any way to scan for this ....????

Thanks in Advance,

Praveen

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,287

Check this program and see if it helps you. Input for this program is hard code value and program name.


REPORT z_detect_hardcode 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.
      try.
      READ REPORT wa_prog-prog INTO i_zprog.
      catch CX_SY_READ_SRC_LINE_TOO_LONG.
      endtry.
      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.

Thanks,

SKJ

Hi Experts,

According to my rek, I need to find out is there any thing hardcoded in the system for the currency.

Is there any way to scan for this ....????

Thanks in Advance,

Praveen

11 REPLIES 11
Read only

0 Likes
2,287

Hardcode are nothing but manually entering the values in the code instead of fetching it from database table or from someother source. Just try to find out the places where the currency value is assigned manually instead of being refered to the source.

regards

Saravanan

Read only

0 Likes
2,287

Hi ,

Thanks for your quick reply.

In my case there are one thousand programs in the system, is there any quick tip to find out the hard coding.

Thanks in Advance,

Praveen

Read only

Former Member
0 Likes
2,287

Hello,

Go to the ABAP Program Extended Syntax Check and mark the option Character Strings, then when you go to the SLIN Overview, double click the lines with warning or errors.

The hardcoded values will be showed.

Regards,

Read only

Former Member
0 Likes
2,288

Check this program and see if it helps you. Input for this program is hard code value and program name.


REPORT z_detect_hardcode 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.
      try.
      READ REPORT wa_prog-prog INTO i_zprog.
      catch CX_SY_READ_SRC_LINE_TOO_LONG.
      endtry.
      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.

Thanks,

SKJ

Read only

0 Likes
2,287

Thanks for your replies.

I dont have access to develop the program in the production system nor I can move from the dev system

Is there any standart program to scan for the hardcoded values.

Please suggest me.

Thanks,

Praveen

Read only

0 Likes
2,287

Hi

Do like below:

Run Program RPR_ABAP_SOURCE_SCAN

Give Z* against Program Names

Now TO GO Table TCURC, put all the WAERS values in one Notepad and import this file againt

FIND STRING on the selection screen

and execute, it will display the lines of Z* programs, where these waers are used as hardcode.

Hope it helps.

Thanks.

Read only

0 Likes
2,286

Thanks Praveen,

Definitely I will try this and will let you know.

and also I want to look for the BUKRS and WAERK fields , what are the tables to look for the values.

Thanks in Advance,

Praveen

Read only

0 Likes
2,286

Hi

Look for table T001 for Bukrs

For waerk is the same table TCURC

Hope this helps.

Thanks,Praveen

Read only

0 Likes
2,286

Hi Praveen,

Thanks for your reply.

How long does it take to run the program, hours to gether ????

Thanks in Advance,

Praveen

Read only

0 Likes
2,286

Hi

Anywhere bet 2-4 Hours.

Depends on string values , if more takes more time.

Praveen

Read only

former_member194669
Active Contributor
0 Likes
2,286

May be use program

RS_ABAP_SOURCE_SCAN