Tuesday, 22 June 2010

SAP - Debugging middleware - OSS Note 847964

Just for my note and quick reference :)

UPDATE: Quick note on ABAP to recreate BDOCis called CRM_START_REQUEST_FROM_CRM.
                         FM: CRM_SRV_R3_LOGISTIC_UPLOAD is called to update PREQ etc.

Symptom

You want to debug the data exchange between CRM and R3 for service documents.

Reason and Prerequisites

Data is sent to the R3 system via the CRM Middleware. The data is sent asynchronously

Solution

Before you save the service document, enter /h and set a breakpoint in
the function module CRM_UPLOAD_BTMBDOC_START_FLOW
Go into the first method, CALL METHOD cl_smw_mflow=>process_outbound (line 33), and set ls_header-dbg_mode to X (line 37). With F8, you'll return to the service order.
Now click on the Doc_flow. You'll see an outbund BDOC with the date BUS_TRANS_MSG and D01.
(If you can't see the BDOC, set the user parameter CRM_USER_LEVEL to 9 in your user parameters).
Double click the BDOC.

Enter /h and set a breakpoint at one of the following function modules:
CRM_R3_ACCOUNTING_UPLOAD passes Controlling information for service contracts and service orders
CRM_R3_SERVICECONF_UPLOAD passes Controlling information for service confirmations
CRM_R3_SRV_RESERVATION_UPLOAD is called for material reservations
CRM_R3_SALESDOCUMENT_UPLOAD is called for sales relevant information (for example, if you have sales items in a service document)
CRM_R3_SERVICE_BILLING_UPLOAD for billing of service orders in R3 (only available with the SIE add-on).
Reprocess the BDOC.
Set a breakpoint at the line IF lv_synchronous_call IS INITIAL or IF gv_synchronous_call IS INITIAL. F8 brings you to this breakpoint.
Set lv_synchronous_call/gv_synchronous_call to X and with F5 you'll enter R3 debugging. Make sure that the RFC user used for communicating between the systems is defined as a dialog user.

--
CRM_SRV_R3_LOGISTIC_UPLOAD
Y_E_CRM_R3_SRV_MVT_UPLOAD

Thursday, 17 June 2010

SAP/SD - Sending order/delivery/invoice via email with body text

This is surely not new, most of us ABAP developers will somehow come across this requirement in some of our project/implementation/support. For those who're on the latest SAP platform, probably you guys are lucky to have the IMPLICIT/EXPLICIT enhancement which you could do to enhance standard SAP function module. But for some of us who're still stuck with 620 or below, we're not so lucky.

Anyway, to share some of the thing that I've done to get the body text work:

  1. You can't use body text in NACE, it just doesn't work that way. Tried it so many times and given up. SAP has a note which says that no matter what you do, it will not work for you :) SAP Note 753622.
  2. Next best thing to do is, to go ahead and change the way the standard SAP send out email in the print program, create an OTF, and just after CLOSE_FORM, use SO_NEW_DOCUMENT_ATT_SEND_API1 or BCS to send the email out. For me, this is too much too.
  3. Probably the best option, do this in FORM_OPEN subroutine in the print program. This is what I've done and it works. Copy the standard RVADOPF0 into customer namespace and replace this in FROM_OPEN subroutine. Add the following code just after the check for retcode eq 0. Create a standard text using SO10 .. text name will be your (output type)_BODY_TEXT.
Here is the code that I've:

DATA: lines_tab LIKE tline OCCURS 0 WITH HEADER LINE,
             obj_name LIKE thead-tdname,
             email_body_text TYPE TABLE OF soli,
             email_line TYPE soli.

CONCATENATE nast-kschl '_BODY_TEXT' INTO obj_name.
CALL FUNCTION 'READ_TEXT'
            EXPORTING
                id = 'ST'
                language = nast-spras
                name = obj_name
                object = 'TEXT'
            TABLES
                lines = lines_tab
            EXCEPTIONS
                id = 1
                language = 2
                name = 3
                not_found = 4
                object = 5
                reference_check = 6
                wrong_access_to_archive = 7
                OTHERS = 8.
LOOP AT lines_tab.
  email_line = lines_tab-tdline.
  APPEND email_line TO email_body_text.
ENDLOOP.
IF email_body_text[] IS NOT INITIAL.
  swc_object_from_persistent lvs_recipient recipient.
  swc_clear_container container.
  swc_set_element container 'NoteText' email_body_text.
  swc_call_method recipient 'AddNote' container.
  swc_object_to_persistent recipient lvs_recipient.
ENDIF.

TOUCHTAB report, regenerate all ABAPs related to changed/modified structure

I was working on S4HANA OnPremis and tried to do an enhancement to BP's additional info structure by appending fields, but decided that ...