Posts

Showing posts from September, 2012

Change Logs For ZTables Using SCDO Transaction Code - 7 (SAP ABAP).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) 15) Now go to SM30. And enter the table name and click on change. 16) Now let’s change the 3rd record‘s discount from 10.00 to 15.00 and save it. On saving the event 01 gets triggered when we have inserted our logic and used the change document function module to update the change log in CDPOS and CDHDR sap log tables. 17) Now let’s check whether the changes has been logged in CDHDR table CDHDR Log Entry as shown: The corresponding entry in CDPOS Table is: In case if you want the complete log for the ZTABLE then you can now create a ZREPORT and fetch all the relevant details to display the LOG in a particular format. <<PREVIOUS PAGE                                                                               ...

Change Logs For ZTables Using SCDO Transaction Code - 6 (SAP ABAP).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) 14) Click On editor and make the following changes as shown: COMPLETE CODE: FORM change_log. DATA : it_zptp_3rd_dis_tes TYPE STANDARD TABLE OF zptp_3rd_dis_tes, wa_old_zptp_3rd_dis_tes TYPE zptp_3rd_dis, wa_new_zptp_3rd_dis_tes TYPE zptp_3rd_dis. DATA: tabix type c. DATA: it_log_table TYPE TABLE OF cdtxt, wa_log_table TYPE cdtxt. SELECT * FROM zptp_3rd_dis_tes INTO TABLE it_zptp_3rd_dis_tes. LOOP AT total. IF <action> IS ASSIGNED AND <vim_total_struc> IS ASSIGNED AND <action> NE space. MOVE <vim_total_struc> TO wa_new_zptp_3rd_dis_tes. READ TABLE it_zptp_3rd_dis_tes INTO wa_old_zptp_3rd_dis_tes WITH KEY ekorg = wa_new_zptp_3rd_dis_tes-ekorg lifnr = wa_new_zptp_3rd_dis_tes-lifnr. tabix = sy-tabix. concatenate 'TE' tabix into wa_log_table-textart separated by '_' . wa_log_table-teilobjid = 'ZPTP_3RD_DIS_TES'. wa_log_table-textart = 'TEST'. wa_log_...

Change Logs For ZTables Using SCDO Transaction Code - 5 (SAP ABAP).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) 11) Now go to SE37 and check the change document function module created. Now this change document object function module is ready to capture all the changes made to the records of the ZTABLE. NOW we need to do some coding so as to capture any changes in sap log tables CDPOS & CDHDR. 12) Consider table ZPTP_3RD_DIS_TES. Generate the table maintenance generator so that user can make new entries, update or delete entries. Go to SE11 --> Table Maintenance Generator. In The modifications Options available on the top of the line, Click EVENTS. 13) We will have to create an event 01 which gets triggered before saving the data in the database as shown: <<PREVIOUS PAGE                                                                        ...

Change Logs For ZTables Using SCDO Transaction Code - 4 (SAP ABAP).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) 8. Now you will see a screen with all the details of the object that will get generated as shown: 9. Click On "SAVE" to complete the program generation for the change document object. You will receive a success message as shown below: 10. Here we can see an update function module gets created which can be used for logging the changes in the SAP standard tables CDPOS & CDHDR. Change logs should be in totality i.e. operations like Insert, Delete & Update functionalities done on the records should get tracked. In order to achieve all the operations we need to add a new variable (or say a flag) of type CHAR1 in the import parameters of the function module. When the value is passed as 'X' and the operation to be performed is 'D' (delete), then the current record will be logged for deletion in CDHDR. <<PREVIOUS PAGE                             ...

Change Logs For ZTables Using SCDO Transaction Code - 3 (SAP ABAP).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) 5. Maintain the text for change document object and the table name, for which the change document object has been created. Then press enter to continue. You will get a screen as shown: 6. Now go to ‘Utilities’ and select ‘Generate Update PGM’. 7. A new screen will be displayed wherein the function group name has to be maintained. Incase if you have a function group name directly maintain it, or else you can create one as shown below: Enter the function group name. In this case we have taken “ZPTP_3RD_DIS_TEST” After entering the function group name press enter, you will get a pop up screen as shown below: Click on “YES” to generate a new function group. <<PREVIOUS PAGE                                                                       ...

Change Logs For ZTables Using SCDO Transaction Code - 2 (SAP ABAP).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) STEP-BY-STEP ANALYSIS – CREATION OF CHANGED DOCUMENT OBJECT: 1. Enter Transaction code SCDO. Click on ‘Create’ button to start the creation of change document object. 2. Enter the name of the change document object in the pop-up screen. Take any name; in this case we have taken ‘ZPTP_3RD_DIS_TE’. Click the Continue button. 3. You get a pop-up screen to confirm the activity is displayed. Select Yes. 4. After pressing YES button, you will be asked to enter the package and the request number to save the object. A new screen appears as shown below: <<PREVIOUS PAGE                                                                                       NEXT PAGE>> ALSO READ: - Change Logs For ZTable...

Change Logs For ZTables Using SCDO Transaction Code - 1 (SAP ABAP).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) In SAP implementation for a business, not all the requirements are covered in the standard SAP tables. Hence, there are possibilities wherein custom tables (ZTABLES) are used to hold important data. This article will help you explain how to track data changes in custom tables (ZTABLES) through standard SAP change tables (CDPOS & CDHDR) . Standard change tables C DHDR and CDPOS are used for tracking the changes made to the standard SAP objects. In case there is a requirement, wherein we need to track the changes made to custom tables i.e. ztables, we need to log those changes in standard SAP change tables (CDPOS & CDHDR). Two major processes involved in tracking the changes of custom tables are – 1) Change document object 2) Function module for the change document object Here we will see step-by-step procedure involved to achieve the same. SCENARIO: In this case we have a ztable wherein discounts are maintaine...

Sample Program On COLLECT Keyword / Statement - 3 (Performance Analysis).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) This sample code on collect keyword will help to give an insight on performance analysis. In this case a sorted internal table is used. SAMPLE CODE: REPORT ztest. TYPES: BEGIN OF x_mara, mtart TYPE mara-mtart, matkl TYPE mara-matkl, brgew TYPE meng15, ntgew TYPE meng15, END OF x_mara. DATA: it_mara TYPE SORTED TABLE OF x_mara WITH NON-UNIQUE KEY mtart matkl WITH HEADER LINE. DATA: v_runtime1 TYPE i, v_runtime2 TYPE i, v_final TYPE i. DATA: v_lines TYPE sy-tabix. GET RUN TIME FIELD v_runtime1. SELECT mtart matkl brgew ntgew FROM mara INTO it_mara . COLLECT it_mara. ENDSELECT. DESCRIBE TABLE it_mara LINES v_lines. DELETE ADJACENT DUPLICATES FROM it_mara COMPARING mtart matkl. DELETE it_mara WHERE ( brgew IS INITIAL ) AND ( ntgew IS INITIAL ). DESCRIBE TABLE it_mara LINES v_lines. GET RUN TIME FIELD v_runtime2. v_final = v_runtime2 - v_runtime1. WRITE: 'Total No. Of rows In This Report: '. WRI...

Sample Program On COLLECT Keyword / Statement - 2 (Performance Analysis).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) This sample code on collect keyword will help to give an insight on performance analysis. SAMPLE CODE: REPORT ztest. TYPES: BEGIN OF x_mara, mtart TYPE mara-mtart, matkl TYPE mara-matkl, brgew TYPE meng15, ntgew TYPE meng15, END OF x_mara. DATA: it_mara TYPE standard TABLE OF x_mara WITH HEADER LINE. DATA: v_runtime1 TYPE i, v_runtime2 TYPE i, v_final TYPE i. DATA: v_lines TYPE sy-tabix. GET RUN TIME FIELD v_runtime1. SELECT mtart matkl brgew ntgew FROM mara INTO it_mara . COLLECT it_mara. ENDSELECT. DESCRIBE TABLE it_mara LINES v_lines. DELETE ADJACENT DUPLICATES FROM it_mara COMPARING mtart matkl. DELETE it_mara WHERE ( brgew IS INITIAL ) AND ( ntgew IS INITIAL ). DESCRIBE TABLE it_mara LINES v_lines. GET RUN TIME FIELD v_runtime2. v_final = v_runtime2 - v_runtime1. WRITE: 'Total No. Of rows In This Report: '. WRITE: v_lines. WRITE:/ 'Total Time Taken To Execute the program (in ms)...

Sample Program On COLLECT Keyword / Statement - 1 (Standard Internal Table).

Image
Submitted By: Shilpa Gunjan (LnT Infotech) This sample code will help you to understand better how collect keyword works or functions. SAMPLE CODE: REPORT zcollect. TYPES: BEGIN OF x_mara, mtart TYPE mara-mtart, matkl TYPE mara-matkl, brgew TYPE mara-brgew, ntgew TYPE mara-ntgew, END OF x_mara. DATA: it_mara type STANDARD TABLE OF x_mara, wa_mara TYPE x_mara. SELECT mtart matkl brgew ntgew FROM mara UP TO 5 ROWS INTO TABLE it_mara WHERE mtart = 'HAWA' AND matkl NE '' AND brgew NE '' AND ntgew NE ''. wa_mara-mtart = 'HAWA'. wa_mara-matkl = 'C01143'. wa_mara-brgew = 100. wa_mara-ntgew = 200. COLLECT wa_mara INTO it_mara. WRITE: / 'Test Program - Collect Keyword - Standard Internal Table. '. LOOP AT it_mara INTO wa_mara. WRITE:/ wa_mara-mtart, wa_mara-brgew, wa_mara-ntgew. ENDLOOP. OUTPUT: Say the five records in the table are: HAWA       P03              100.000     100.000 HAWA ...