Skip to Content
avatar image
Former Member

Masking Keyfields

Hi experts ,

We are copying data from quality server to development . Here the original employee details of the client(that is some key fields ex: bank id ,address) should be masked using ABAP code .so how can we proceed.

Thanks in advance.

Rgds,

devika.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Aug 22, 2007 at 05:12 AM

    Hi Below is the sample program go thr that :

    **********************************************************************************

    REPORT zavaya_mask_vendor_addr MESSAGE-ID b1.

    • This program is to mask the values of fax_number of ADR3, STMP_ADDR of

    • ADR6 and SMTP_SRCH of ADR6 table. Values of all the above mentioned

    • fileds will be set blank for corresponding values of ADRNR field in

    • LFA1 table.

    TYPES: BEGIN OF ty_addr, "TYPE FOR LFA1 TABLE

    adrnr TYPE lfa1-adrnr,

    END OF ty_addr.

    TYPES: BEGIN OF ty_adr3, "TYPE FOR ADR3 TABLE

    client TYPE adr3-client,

    addrnumber TYPE adr3-addrnumber,

    persnumber TYPE adr3-persnumber,

    date_from TYPE adr3-date_from,

    consnumber TYPE adr3-consnumber,

    fax_number TYPE adr3-fax_number,

    END OF ty_adr3.

    TYPES: BEGIN OF ty_adr6, "TYPE FOR ADR6 TABLE

    client TYPE adr6-client,

    addrnumber TYPE adr6-addrnumber,

    persnumber TYPE adr6-persnumber,

    date_from TYPE adr6-date_from,

    consnumber TYPE adr6-consnumber,

    smtp_addr TYPE adr6-smtp_addr,

    smtp_srch TYPE adr6-smtp_srch,

    END OF ty_adr6.

    DATA: i_lfa1 TYPE STANDARD TABLE OF ty_addr INITIAL SIZE 0,

    i_adr3 TYPE STANDARD TABLE OF ty_adr3 INITIAL SIZE 0,

    wa_adr3 TYPE ty_adr3,

    i_adr6 TYPE STANDARD TABLE OF ty_adr6 INITIAL SIZE 0,

    wa_adr6 TYPE ty_adr6,

    wa_tddat TYPE tddat.

    DATA: g_commit_rec_count LIKE sy-index, "COUNTER FOR 200 RECORDS

    g_total_rec_upd LIKE sy-index. "COUNTER FOR WHOLE RECORDS

    AT SELECTION-SCREEN.

    PERFORM check_not_production.

    PERFORM AUTH_CHECK using 'ADR3'.

    PERFORM AUTH_CHECK using 'ADR6'.

    START-OF-SELECTION.

    SELECT adrnr FROM lfa1 INTO TABLE i_lfa1.

    SORT i_lfa1.

    DELETE ADJACENT DUPLICATES FROM i_lfa1.

    DELETE i_lfa1 WHERE adrnr EQ space.

    IF NOT i_lfa1 IS INITIAL.

    PERFORM update_adr3. "FOR UPDATION ON ADR3 TABLE

    PERFORM update_adr6. "FOR UPDATION ON ADR6 TABLE

    ENDIF.

    &----


    *& Form AUTH_CHECK

    &----


    FORM auth_check using p_tab type tddat-tabname.

    SELECT SINGLE * FROM tddat INTO wa_tddat WHERE tabname = p_tab.

    IF sy-subrc = 0 AND wa_tddat-cclass NE space.

    AUTHORITY-CHECK OBJECT 'S_TABU_DIS'

    ID 'DICBERCLS' FIELD wa_tddat-cclass

    ID 'ACTVT' FIELD '02'.

    IF sy-subrc <> 0.

    MESSAGE ID 'B1' TYPE 'E' NUMBER '125'

    WITH 'S_TABU_DIS' '03' '' ''.

    ENDIF.

    ENDIF.

    ENDFORM. " AUTH_CHECK

    &----


    *& Form CHECK_NOT_PRODUCTION

    &----


    FORM check_not_production.

    IF sy-sysid+2(1) = 'P'.

    MESSAGE e999 WITH

    'This program may not be run in production'.

    ENDIF.

    ENDFORM. " CHECK_NOT_PRODUCTION

    &----


    *& Form OBTAIN_SAP_TABLE_LOCK

    &----


    • This function obtains a lock on object RSTABLE for SPECIFIED TABLE

    • its purpose is to prevent job from being submitted twice

    • during same time frame. Does not lock table at oracle

    • level.

    FORM obtain_sap_table_lock USING p_tab TYPE rstable-tabname.

    CALL FUNCTION 'ENQUEUE_E_TABLE'

    EXPORTING

    • mode_rstable = 'E'

    tabname = p_tab

    • VARKEY =

    • X_TABNAME = ' '

    • X_VARKEY = ' '

    • _SCOPE = '2'

    • _WAIT = ' '

    • _COLLECT = ' '

    EXCEPTIONS

    foreign_lock = 1

    system_failure = 2

    OTHERS = 3.

    IF sy-subrc <> 0.

    MESSAGE e999 WITH

    'Cannot get SAP lock on the table ' p_tab.

    ENDIF.

    ENDFORM. " OBTAIN_SAP_TABLE_LOCK

    &----


    *& Form RELEASE_SAP_TABLE_LOCK

    &----


    FORM release_sap_table_lock USING p_tab TYPE rstable-tabname.

    CALL FUNCTION 'DEQUEUE_E_TABLE'

    EXPORTING

    • MODE_RSTABLE = 'E'

    tabname = p_tab

    • VARKEY =

    • X_TABNAME = ' '

    • X_VARKEY = ' '

    • _SCOPE = '3'

    • _SYNCHRON = ' '

    • _COLLECT = ' '

    EXCEPTIONS

    OTHERS = 1.

    IF sy-subrc <> 0.

    MESSAGE e999 WITH

    'Cannot release lock of table ' p_tab ' - call programmer.'.

    ENDIF.

    ENDFORM. " RELEASE_SAP_TABLE_LOCK

    &----


    *& Form UPDATE_ADR3

    &----


    • THIS WILL UPDATE THE FAX_NUMBER FIELD IN ADR3 TABLE.

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM update_adr3.

    ULINE.

    WRITE: / 'REPORT FOR TABLE ADR3'.

    ULINE.

    g_total_rec_upd = 0.

    g_commit_rec_count = 0.

    PERFORM obtain_sap_table_lock USING 'ADR3'.

    SELECT client addrnumber persnumber date_from consnumber fax_number

    FROM adr3

    INTO TABLE i_adr3

    FOR ALL ENTRIES IN i_lfa1

    WHERE addrnumber = i_lfa1-adrnr.

    DELETE i_adr3 WHERE fax_number EQ space.

    SORT i_adr3 BY client addrnumber persnumber date_from consnumber.

    LOOP AT i_adr3 INTO wa_adr3.

    ADD 1 TO g_total_rec_upd.

    ADD 1 TO g_commit_rec_count.

    UPDATE adr3 CLIENT SPECIFIED

    SET fax_number = ''

    WHERE client = wa_adr3-client

    AND addrnumber = wa_adr3-addrnumber

    AND persnumber = wa_adr3-persnumber

    AND date_from = wa_adr3-date_from

    AND consnumber = wa_adr3-consnumber.

    IF sy-subrc <> 0.

    WRITE: / 'Error - db update not successful - call programmer.'.

    WRITE: / 'Return code = ', sy-subrc.

    WRITE: / ' Client = ', wa_adr3-client.

    WRITE: ' Address number = ', wa_adr3-addrnumber.

    WRITE: ' Person number = ', wa_adr3-persnumber.

    WRITE: ' Date valid from = ', wa_adr3-date_from.

    WRITE: ' Sequence number = ', wa_adr3-consnumber.

    ROLLBACK WORK.

    MESSAGE e999 WITH

    'Error on db update - call programmer.'.

    ENDIF.

    IF g_commit_rec_count = 200.

    COMMIT WORK.

    WRITE: / 'commit work at record ', g_total_rec_upd,

    'return code = ', sy-subrc.

    g_commit_rec_count = 0.

    ENDIF.

    ENDLOOP.

    COMMIT WORK. "release remaining records to db

    WRITE: / 'final commit work at record ', g_total_rec_upd,

    'return code = ', sy-subrc.

    PERFORM release_sap_table_lock USING 'ADR3'.

    WRITE: / 'total number of records updated: ',

    g_total_rec_upd.

    ENDFORM. " UPDATE_ADR3

    &----


    *& Form UPDATE_ADR6

    &----


    • THIS IS TO UPDATE VALUES OF SMTP_ADDR NAD SMTP_SRCH FILEDS IN

    • ADR6 TABLE.

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM update_adr6.

    ULINE.

    WRITE: / 'REPORT FOR TABLE ADR6'.

    ULINE.

    g_total_rec_upd = 0.

    g_commit_rec_count = 0.

    PERFORM obtain_sap_table_lock USING 'ADR6'.

    SELECT client addrnumber persnumber date_from consnumber

    smtp_addr smtp_srch

    FROM adr6

    INTO TABLE i_adr6

    FOR ALL ENTRIES IN i_lfa1

    WHERE addrnumber = i_lfa1-adrnr.

    DELETE i_adr6 WHERE smtp_addr EQ space AND smtp_srch EQ space.

    SORT i_adr6 BY client addrnumber persnumber date_from consnumber.

    LOOP AT i_adr6 INTO wa_adr6.

    ADD 1 TO g_total_rec_upd.

    ADD 1 TO g_commit_rec_count.

    IF wa_adr6-smtp_addr NE space.

    wa_adr6-smtp_addr = ''.

    ENDIF.

    IF wa_adr6-smtp_srch NE space.

    wa_adr6-smtp_srch = ''.

    ENDIF.

    UPDATE adr6 CLIENT SPECIFIED

    SET smtp_addr = wa_adr6-smtp_addr

    smtp_srch = wa_adr6-smtp_srch

    WHERE client = wa_adr6-client

    AND addrnumber = wa_adr6-addrnumber

    AND persnumber = wa_adr6-persnumber

    AND date_from = wa_adr6-date_from

    AND consnumber = wa_adr6-consnumber.

    IF sy-subrc <> 0.

    WRITE: / 'Error - db update not successful - call programmer.'.

    WRITE: / 'Return code = ', sy-subrc.

    WRITE: / ' Client = ', wa_adr6-client.

    WRITE: ' Address number = ', wa_adr6-addrnumber.

    WRITE: ' Person number = ', wa_adr6-persnumber.

    WRITE: ' Date valid from = ', wa_adr6-date_from.

    WRITE: ' Sequence number = ', wa_adr6-consnumber.

    ROLLBACK WORK.

    MESSAGE e999 WITH

    'Error on db update - call programmer.'.

    ENDIF.

    IF g_commit_rec_count = 200.

    COMMIT WORK.

    WRITE: / 'commit work at record ', g_total_rec_upd,

    'return code = ', sy-subrc.

    g_commit_rec_count = 0.

    ENDIF.

    ENDLOOP.

    COMMIT WORK. "release remaining records to db

    WRITE: / 'final commit work at record ', g_total_rec_upd,

    'return code = ', sy-subrc.

    PERFORM release_sap_table_lock USING 'ADR6'.

    WRITE: / 'total number of records updated: ',

    g_total_rec_upd.

    ENDFORM. " UPDATE_ADR6

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 22, 2007 at 05:18 AM

    Hi,

    Try to use these function module, it will encrypt and decrpt the data

        call function 'FIEB_PASSWORD_ENCRYPT' 
             exporting 
                  im_decrypted_password = intext 
             importing 
                  ex_encrypted_password = outtext. 
      
    ******** Decrypting ******************* 
        call function 'FIEB_PASSWORD_DECRYPT' 
             exporting 
                  im_encrypted_password = intext 
             importing 
                  ex_decrypted_password = outtext. 
    
    

    aRs

    Message was edited by:

    Add comment
    10|10000 characters needed characters exceeded