Friday 1 November 2013

Transferring table records from One Client to Another Client in same SAP System with customr report By using ALE IDOC

Step1. Go to Tcode-Se11.











Step2. Provide the table name and click on create button.

















Step3. Provide the detail fields and activate the table. Create some records.

















Step4. The records of the table are displayed below.




















Step5. The same table is available in the client 300.


















Step6. There are no records present in the table for the client 300.















Step7. Go to Tcode- SALE.












Step8. Navigate along the highlighted path to create logical systems.

















Step9. Create two logical systems for the client 200 and 300.













Step10. Save it and click on the BACK button.



















Step11. Click on the highlighted line to assign the logical systems to the clients.
















Step12. Double  Click on the client-200.















Step13. Maintain the logical system , click on save and then click on  Back button. Then double click on client 300.














Step14. Provide the logical system for the client 300, save it and at last click on Back button.
















Step15. Click on the highlighted line to create rfc destination or go to tcode- SM59.
















Step16. Select the ABAP Connection type and click on Create Button.













Step17. Provide the details and save it. Click on the connection the button.















Step18. The connection works fine.














Step19. Now logon to the 300 client and create a rfc destination. Provide the details, save it and at last click on Connection Test button.














Step20. The RFC connection works fine.














Step21. Now go to Tcode- WE21 to create port.












Step22. Select the transactional RFC line and click on the create button.
















Step23. Select the first line and click on continue button.















Step24. The system automatically creates a port number, provide the description and the RFC destination name and save it.




















Step25. Now go to client 300. Go to Tcode- WE21.











Step26. Select the transactional RFC line and click on the create button.

















Step27. Select the first line and click on continue button.

















Step28. The system automatically creates a port number, provide the description and the RFC destination name and save it.



















Step29. Now in client-200 , go to Tcode- WE31.










Step30. Provide the segment name and click on the create button.












Step31. Provide the short text, the fields of the table with data element and click on the save button.






















Step32. Click the continue button.




















Step33. Save it and click on Back button.





















Step34. Again click on Back button.

















Step35. Now go to Tcode- SE11.











Step36.  Provide the segment name and click on display button.
















Step37. The system automatically creates a structure with the name of the segment.




















Step38. Now go to Tcode- WE30 to asisgn the segment the the IDOC type.












Step39. Provide the IDOC type name and click on Create button.
















Step40. Select the create New radio button and provide the description and click on continue button.





















Step41. Select the Idoc type and click on the Create button.











Step42.  Provide the segment name created above. Select it as Mandatory segment and at last click on the Continue button.



















Step43. Now click on the Edit menu and Click Set Release .


















Step44. Click on Yes button to continue.















Step45. Save it and click on Back button,
















Step46. Now go to Tcode- SE81 to create a message type.










Step47. Click on Edit and the New Entries button.

















Step48. Provide a message type and short text and save it. At last click on Back button.

















Step49. Now go to Tcode- WE82 to assign message type to Idoc.










Step50. Click on the Edit button.















Step51. Click on New Entries button.















Step52. Provide the above created message type, Idoc name and release and Save it. At last click on Back button.


















Step53. Now go to Tcode- BD64 to create Customer Distribution Model.











Step54. Click on Edit button.













Step55. Now click on Create Model view.













Step56. Provide Technical name, short text and click on Continue button.













Step57. Now click on Add Message Type button.














Step58. Provide the sender logical system, receiver logical system, message type and click on Yes button.














Step59. Now the Customer Distribution model looks like as shown below.
















Step60. Select the distribution model and from the Environment menu click on generate partner profiles.


















Step61. Execute the program.

























Step62. It generates the partner profiles LS_300 and LS_200.


















Step63. Lets go to the Tcode WE20 to edit the generated partner profiles.









Step64. Under the partner type LS, select the LS_300. Click on  the Add button as highlighted under Outbound Parameters.
























Step65. Provide the message type, port and Idoc type, save it and click on back button.

























Step66. Now the message type is added under the outbound parameter.























Step67. Go to Tcode- BD64, select the customer distribution model and from the environment menu click on Generate Partner profile.




















Step68. Execute the below program.

























Step69. There is no red line. So all teh set up is fine.


















Step70. Now go to Tcode - We20 to see again the partner profile.  The SYNCH message type is automatically added to the partner profile LS_300 when it is generated. Now double click on teh message type SYNCH.
























Step71.  The port and other details are automatically automatically assigned. Save it and go back.



























Step72. Now go to teh tcode- BD64, Select the Customer distribution model and Navigate along the highlighted path to distribute the Distribution model.




















Step73. Select the receiver model view as LS_300.
























Step74. Now the distribution model is created in the target client (300).













Step75. Now go to Tcode- SE38.












Step76. Provide a report name and create  it.











Step77. Provide the below code and activate it.






















______________________________________________________________________________
REPORT  zpgm_country_tax_det_transfer.

CLASS lcl_cntry_tax DEFINITION.
  PUBLIC SECTION.
    CONSTANTS  : c_idcotype TYPE edidc-idoctp VALUE 'ZCNTRY_TAX_IDOC',
                             c_msgtype TYPE edidc-mestyp VALUE  'ZCNTRY_TAX_MSG',
                             c_port TYPE edidc-rcvpor VALUE 'A000000035',
                             c_rec_part_type TYPE edidc-rcvprt VALUE 'LS',
                             c_rec_sys TYPE edidc-rcvprn VALUE 'LS_300',
                            c_sndr_part_type TYPE edidc-sndprt VALUE 'LS',
                            c_sndr_sys TYPE edidc-sndprn VALUE 'LS_300'.
    DATA : coun_code TYPE zcntry_tax_code-countyr,
                lt_cnty_tax TYPE TABLE OF zcntry_tax_code,
                ls_cnty_tax TYPE zcntry_tax_code,
                lt_data TYPE TABLE OF edidd,
                ls_data TYPE edidd,
                lt_comm_idoc TYPE TABLE OF edidc,
                ls_comm_idoc TYPE edidc,
                ls_control TYPE edidc.
    METHODS : constructor IMPORTING i_coun_code TYPE zcntry_tax_code-countyr,
                        prepare_data,
                        prepare_cntl_data,
                        send_idoc.
ENDCLASS.                    "lcl_cntry_tax DEFINITION


CLASS lcl_cntry_tax IMPLEMENTATION.
  METHOD constructor.
    coun_code = i_coun_code.
  ENDMETHOD.                    "constructor
  METHOD prepare_data.
    DATA : ls_seg TYPE zcntry_tax_seg.
    SELECT  * FROM zcntry_tax_code INTO TABLE  lt_cnty_tax WHERE countyr = coun_code.
    IF sy-subrc = 0.
      LOOP AT lt_cnty_tax INTO ls_cnty_tax.
        ls_data-segnam  = 'ZCNTRY_TAX_SEG'. " segment name
        ls_seg-countyr = ls_cnty_tax-countyr.
        ls_seg-tax_code = ls_cnty_tax-tax_code.
        ls_data-sdata = ls_seg.
        APPEND ls_data TO lt_data.
        CLEAR ls_data.
      ENDLOOP.
    ELSE.
      MESSAGE 'No record found' TYPE 'E'.
    ENDIF.
  ENDMETHOD.                    "prepare_data
  METHOD prepare_cntl_data.
    ls_control-idoctp = c_idcotype.
    ls_control-mestyp = c_msgtype.
    ls_control-rcvpor = c_port.
    ls_control-rcvprt = c_rec_part_type .
    ls_control-rcvprn = c_rec_sys.
    ls_control-sndprt = c_sndr_part_type .
    ls_control-sndprn = c_sndr_sys.

  ENDMETHOD.                    "prepare_cntl_data
  METHOD send_idoc.
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
      EXPORTING
        master_idoc_control            = ls_control
*       OBJ_TYPE                       = ''
*       CHNUM                          = ''
      TABLES
        communication_idoc_control     = lt_comm_idoc
        master_idoc_data               = lt_data
      EXCEPTIONS
        error_in_idoc_control          = 1
        error_writing_idoc_status      = 2
        error_in_idoc_data             = 3
        sending_logical_system_unknown = 4
        OTHERS                         = 5.
    IF sy-subrc = 0.
      LOOP AT lt_comm_idoc INTO ls_comm_idoc.
        WRITE :/ 'Idoc Generated : ', ls_comm_idoc-docnum.
      ENDLOOP.
    ENDIF.

  ENDMETHOD.                    "send_idoc
ENDCLASS.                    "lcl_cntry_tax IMPLEMENTATION

START-OF-SELECTION.
  PARAMETERS : p_cntry TYPE zcntry_tax_code-countyr.
  DATA  : obj TYPE REF TO lcl_cntry_tax.

  CREATE OBJECT obj
    EXPORTING
      i_coun_code = p_cntry.
  CALL METHOD obj->prepare_data.
  CALL METHOD obj->prepare_cntl_data.
  CALL METHOD obj->send_idoc.

______________________________________________________________________________
Step78. All the set up with the custom report in the source client 200 is ready. Now logon to the client 300. Go to Tcode- SE80.











Step79.  Create a function group. Provide the name and hit the enter button. From the popup click on Yes button.









Step80. Activate the Function Group.


















Step81. Now go to Tcode- SE37 .










Step82. Now Provide a function module name and click on the create button.













Step83. Provide the above created function group name and description and click on Save button.














Step84. Provide the Importing parameters as shown below.













Step85.  Provide the Exporting parameters as shown below.















Step86.  Provide the parameters under the Tables section as shown below.
















Step87.  Provide the Exception as shown below.
















Step88. Maintain the below code.























FUNCTION zcountyr_tax_code_update.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(INPUT_METHOD) TYPE  BDWFAP_PAR-INPUTMETHD
*"     REFERENCE(MASS_PROCESSING) TYPE  BDWFAP_PAR-MASS_PROC
*"  EXPORTING
*"     REFERENCE(WORKFLOW_RESULT) TYPE  BDWF_PARAM-RESULT
*"     REFERENCE(APPLICATION_VARIABLE) TYPE  BDWF_PARAM-APPL_VAR
*"     REFERENCE(IN_UPDATE_TASK) TYPE  BDWFAP_PAR-UPDATETASK
*"     REFERENCE(CALL_TRANSACTION_DONE) TYPE  BDWFAP_PAR-CALLTRANS
*"  TABLES
*"      IDOC_CONTRL STRUCTURE  EDIDC
*"      IDOC_DATA STRUCTURE  EDIDD
*"      IDOC_STATUS STRUCTURE  BDIDOCSTAT
*"      RETURN_VARIABLES STRUCTURE  BDWFRETVAR
*"      SERIALIZATION_INFO STRUCTURE  BDI_SER
*"  EXCEPTIONS
*"      WRONG_FUNCTION_CALLED
*"----------------------------------------------------------------------
  INCLUDE mbdconwf.
  DATA : ls_seg TYPE zcntry_tax_seg,
         lt_cnty_tax TYPE TABLE OF zcntry_tax_code,
         ls_cnty_tax TYPE zcntry_tax_code.
  workflow_result = c_wf_result_ok.
  LOOP AT idoc_contrl.
    IF idoc_contrl-mestyp = 'ZCNTRY_TAX_MSG'.
      LOOP AT  idoc_data.
        ls_seg = idoc_data-sdata.
        MOVE-CORRESPONDING ls_seg TO ls_cnty_tax.
        APPEND ls_cnty_tax TO lt_cnty_tax.
      ENDLOOP.
      MODIFY zcntry_tax_code FROM TABLE lt_cnty_tax.
      IF sy-subrc = 0.
        idoc_status-docnum = idoc_contrl-docnum.
        idoc_status-status = '53'.
        idoc_status-msgv1 =  ls_cnty_tax-countyr.
        APPEND idoc_status.
        CLEAR idoc_status.
      ELSE.
        idoc_status-docnum = idoc_contrl-docnum.
        idoc_status-status = '51'.
        idoc_status-msgv1 =  ls_cnty_tax-countyr.
        APPEND idoc_status.
        CLEAR idoc_status.
        workflow_result = c_wf_result_error.
        return_variables-wf_param = 'Error_Idocs'.
        return_variables-doc_number = idoc_contrl-docnum.
        APPEND return_variables.
        CLEAR return_variables.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDFUNCTION.
_____________________________________________________________________________
Step89. Now go to Tcode- WE57 to assign the Function module to the Idoc type.










Step90. Click on Edit button.
















Step91. Clcik on New Entries.
















Step92. Provide the Function module name, Idoc name and message type. Save it and clcik on back button.























Step93. The line appears in the list.
















Step94. Now go to Tcode- BD51 .











Step95. click On New Entries.

















Step96. Provide the Function Module name and maintain value as 2 under input section as a inbound function module.
















Step97. Now go to Tcode- WE42.









Step98. Click on Edit button.













Step99. Click on New Entries button.













Step100. Provide a Processing Code name with description. Select the radio buttons as highlighted below. Save it and click on back button.























Step101. Here provide the Inbound function module name, save it and click on Back button.


























Step102. Now double click on the logical message  line highlighted in the left hand side.





















Step103. Click on New Entries button.













Step104. Provide the message type name, save it and click on the Back button.


















Step105. Click on the Back button.


















Step106. Now go to Tcode- BD64 to generate the partner profile from the Customer distribution model.










Step107. Select the Distribution model, From the Environment menu click on Generate Partner profile .



















Step108. Execute the program.






























Step109. The partner profiles LS_200 and Ls_300 are generated.


















Step110. Now go to Tcode- WE20 to see the partner profiles.











Step111. Under the Partner Type 'LS' select the partner profile LS_200. The message type ZCNTRY_TAX_MSG is already added in the Inbound parameters section. Now click on the Add button under the Outbound parameters section.
























Step112. Provide the message type, port, basic idoc type, save it and at last click on back button.























Step113. Now double click on the Message type  ZCNTRY_TAX_MSG under the Inbound parameters.






















Step114. The generated processing code is assigned to the message type.























Step115. Now go to Tcode- BD64 to generate the partner profile from the Customer distribution model. Select the Distribution model, From the Environment menu click on Generate Partner profile . Execute the program.



























Step116. There are no red lines. So all set up is done in the client 300 to receive the Idoc.





















Step117. Now go the client-200 and execute the report.



















Step118. Provide the country name and execute it.











Step119. The idoc generated 203039.













Step120.  Again execute the report and Provide the country name and execute it.












Step121. The idoc generated 203040.












Step122. Now go to Tcode- WE02 in the  client 200 to see the Idoc details.Provide the idoc numbers and execute it.

















Step123. Now the idoc status is 30(ready for dispatch to the port). If the status is 03 then idoc is dispatched.

















Step124. Go to SE38 and execute the report RSEOUT00 .














Step125. Provide the Idoc numbers and execute it.














Step126. clckc on the continue button.














Step127. Now again go to tcode- WE02 and provide the Idoc numbers and execute it.

















Step128. Now the idoc status is 03 with green status. Double click on each idoc to see the details of it.
















Step129. The IDOC- 203039 contains the details as shown below.

























Step130.  The IDOC- 203040 contains the details as shown below.
























Step131. Now go to code- WE02 in the client 300.












Step132. Provide the Idoc type name and execute the report.




















Step133. Now the idocs are with status 56 with red status.














Step134. Go to Tcode WE19 and provide the inbound Idoc number.











Step135. Provide the Inbound Idoc number and execute it.
















Step136. Now click on Inbound Function Module name .


















Step137. From the popup, select the Call in debugging mode check box and Select the radio button In foreground and then click on Continue button.















Step138.
















Step139. Now go to SE11 and open the table and go to the contents button. Provide the country name UK and execute it.














Step140. The Record is available in the client 300.













_______________________________________________________________________________


1 comment:

Matt said...

A lot of steps are involved just to transfer some table data from one client to another. Not sure how to remember all these steps. Moreover, in the real time, there will be much tougher scenarios am sure :-(

Comments system

Disqus Shortname