Application Development 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: 

Change Documents Some Doubts and clarification.

Former Member
0 Kudos

hello all,

i have just started learning concept of SAP Change Documents.

I got almost everything of it (i guess), except the last and final step.

i have read many times, as there are many WIKI available and doc's also.

But none of them has exactly shown and explained the last step(most  of them has just copied documentation from sap help site).

What i am taking about:

After update Prog has been generated, all 4 include and  FM is generated.

Where and WHY exactly there is need to write abap code and define these includes in that prog.

Please guide me, if i create a new prog in SE38, and create a entry in DB table, how the hell this newly created prog came o know

that the new entry has been created in that DB table and i have to execute myself in order to log the changes.

I am posting screen-shot of the include and FM generated and please guide me ahead.

more over, i have tried to display this generated FM in SE37, but it says that the FM does not exist. WHY?

6 REPLIES 6

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

When I write my own maintenance programs I use those functions in sequence (see the functions documentation):

CALL FUNCTION 'CHANGEDOCUMENT_OPEN'

CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE'

CALL FUNCTION 'CHANGEDOCUMENT_CLOSE'

This is good for single table update .

Other useful functions :

CALL FUNCTION 'CHANGEDOCU_KEY_ANY2CHAR'

CALL FUNCTION 'CHANGEDOCUMENT_READ'

CALL FUNCTION 'CHANGEDOCUMENT_DISPLAY'

Please search in SCN for CHANGEDOCUMENT_SINGLE_CASE

Regards.

Former Member
0 Kudos

Hi Abhishek,

Since you are creating your own change document,You have to call *_WRITE_DOCUMENT FM from some place . you must call the FM via the generated include in your update program . In case customized fields , it could be a BADI  for save / Update .

Did you tried the below URL , i think it explains more in detail .

Maintaining Change Log for Database Tables - ABAP Development - SCN Wiki

Sarath

0 Kudos

sarath,

i exactly understand wht you are trying to say.

What i  want to ask:

please consider this as per my example.

i have created ztable ZHR_TAB and its 1 fields have data element on which changed doc checkbox is ticked.

Now i have created a table maintenance generator for this table and implemented 1 of its event in table maintaince ... i.e create_enrty event. ( of course in order to log changes and some other changes while creating a new entry in table).

have a look at the code . i have not mentioned any of the includes which were created while generating update prog  in SCDO.


Just called this FM directly.

Dont have any idea will it work  or not but as f now help me with the FM parameters.

Also, let me know which include i have to include here.

See screen-shots in earlier posts for the includes which were generated in update prog in SCDO.

Also, please put some light on concept of Single Case and Mutiple case.

the wiki abt which u r taking abt does not shed light on these concept's definition and their need.

I mean which to use when.

0 Kudos

Hi Abhishek,


If it is a independent program, this is the way I worked in long back. With slight change , I hope  you can implement for a table maintenance . 

FZCDHRCDT must be included in TOP include, this is having  the data declarations.

FZCDHRCDC  is included in the function pool main program.

I am talking here about a multiple case.

Take the internal table with the values you are going to update/insert. Move this to the N-table.

Select the current values from the table into O-table for all entries in the N-table.

If the N-record has a corresponding O-record, then mark x-flag as 'U' else 'I'.

Call the subroutine  FORM cd_call*  after modifying the records . 

Multiple or single case is defined by one check box on the change doc object creation. If it is  an 'X' on the copy as internal table field you will have a multiple case  else  will remain as  single case.

If you intend to change only one record at a time you can very well use the single case (use New or old work areas).If the requirement is to change multiple records at the same time go for multiple case. You will need to build N and O tables only for the multiple case scenario.

Go to se37 and search for  *_WRITE_DOCUMENT , and do some code walk through via where used list . this may help you to get some example .


Sarath

0 Kudos

still sarath,

i am at same position from where i started.

firstly i guess create_entry is the wrong place to call this FM.

it should be at save. (please correct me if i am wrong).

secondly suppose i am creating new entry then old table will be blank.


Also,

i can see in FM source code that *_write_document calls

CALL FUNCTION 'CHANGEDOCUMENT_OPEN'

and CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE'

and  CALL FUNCTION 'CHANGEDOCUMENT_CLOSE' itself.


then why do we need to explicitly call these FM (or we dont need).

Please sarath, explain in my language i have mentioned and ztable and howand with which parameters i should call write_docment FM or do i need to call it in update task.????



Former Member
0 Kudos

I have created a new prog where i am updating custom created table and along with it i am calling *_write_document FM.

Please see code .

Prob is Ztable is updated but CDHDR AND CDPOS are not getting updated. please guide me where i am wrong.


data :OBJECTID TYPE CDHDR-OBJECTID.

DATA  :N_ZHR_TAB type zhr_tab,

      O_ZHR_TAB type zhr_tab.

DATA  ICDTXT_ZCDHR tYPE STANDARD TABLE OF CDTXT WITH HEADER LINE..

start-of-selection.

select single * from zhr_tab into O_ZHR_TAB .

   n_ZHR_TAB = O_ZHR_TAB.

   n_ZHR_TAB-EMP_TYP = 'PS'.

   update zhr_tab from n_ZHR_TAB.

   OBJECTID = 'ZHR_TAB'.

CALL FUNCTION 'ZCDHR_WRITE_DOCUMENT' IN UPDATE TASK

   EXPORTING

     OBJECTID                      = OBJECTID

     TCODE                         = sy-TCODE

     UTIME                         = sy-uzeit

     UDATE                         = sy-datum

     USERNAME                      = sy-uname

*   PLANNED_CHANGE_NUMBER         = ' '

    OBJECT_CHANGE_INDICATOR       = 'U'

*   PLANNED_OR_REAL_CHANGES       = ' '

*   NO_CHANGE_POINTERS            = ' '

*   UPD_ICDTXT_ZCDHR              = ' '

     N_ZHR_TAB                     = N_ZHR_TAB

     O_ZHR_TAB                     = O_ZHR_TAB

    UPD_ZHR_TAB                   = 'U'

   TABLES

     ICDTXT_ZCDHR                  = ICDTXT_ZCDHR

           .

COMMIT WORK AND WAIT.