You are on page 1of 5

March 2008 www.SAPexperts.


Troubleshoot and Track BDoc Messages in SAP CRM

by Pavan Kumar Sunkara, Senior SAP Architect, SITA Corp.
See how you can use a Business Document monitoring process in CRM Middleware to quickly uncover errors when transferring data between SAP CRM and SAP ERP Central Component.

>> Key Concept

CRM Middleware uses Business Document (BDoc) messages in queued Remote Function Calls when transferring data between SAP CRM and another system, such as SAP ERP Central Component. BDoc messages are based on BDoc types, which contain all the information for a particular business process, such as a collection of data related to a particular business partner. Message ID field. The system assigns this

On a recent job, the client had SAP ERP Central Component (ECC) 5.0 and SAP CRM 2005. With the large volume of data loads that move between ECC and SAP CRM, a significant number of Business Documents (BDocs) flow through queues. Usually the BDocs flow smoothly through the queues, but sometimes they become stuck in the queues due to errors. My task was to devise a way to monitor BDocs in SAP CRM to troubleshoot these errors. For example, you could encounter an error when a business object is changed in the CRM Server, but ECC doesnt receive this change. The same goes for the reverse process SAP CRM may not reflect changes on the ECC side. SAP CRM doesnt offer a systematic approach to troubleshooting and BDoc monitoring, so I devised the following procedure to streamline the BDoc monitoring process. Ill show you a way to identify the BDoc error, find out where it occurred, locate the BDoc in the queue, and reprocess the BDoc.

For the BDoc Type (Generation Name), enter the BDoc type to use as a filter, such as BUPA_MAIN for a business partner message, BUS_TRANS_MSG for a transaction (order) message, or PRODUCT_MAT for a product message. For example, if you want to display all the error BDocs related to business transactions, enter BUS_ TRANS_MSG in the BDoc Type field to filter BDoc errors by transaction. If you want to display a particular BDoc and you know the 32-digit, unique BDoc ID, such as 464C8CA65C9E00AD00000 000C0A870B2, enter it in the BDoc

ID after it generates the BDoc. You can ignore this parameter if you dont know the BDoc ID. In this case, the system displays all the BDocs based on the BDoc type. You

Analyze the BDoc Messages

The first step in correcting the error is to analyze the BDoc messages, which you can access via transaction SMW01 (display BDoc messages) or via menu path Middleware>Monitoring>Message Flow>Display BDOC Messages. This takes you to the selection screen in Figure 1 in which you enter certain parameters to get information about specific errors.

Figure 1 Selection screen for transaction SMW01 (display BDoc error messages)

For group rates on electronic access, call 1-781-751-8799


can use the User (Creator) field to filter BDocs based on a given user. The BDoc State describes the current processing of a BDoc. Table 1 shows the possible statuses for this field. Usually you encounter BDocs with a status that starts with an E or F. Statuses with an F are final and mean that the system processed the BDoc after initially encountering an error. Statuses with an E are error statuses that you must correct manually. Finally, if you want to display inbound BDocs, select the Inbound check box in the Flow Context area. To display outbound BDocs, select the Outbound check box. After entering the filter criteria in Figure 1, press F8 to execute the transaction with your selection parameters. The screen in Figure 2 appears. In the State field you see three circles. Successfully processed messages have the right circle shaded in green, those still in process have the middle circle shaded in yellow, and those with a terminal error condition have the left circle shaded in red. If a message is in process and the system does not process it within a reasonable amount of time, you can restart, view, or

discard the message. The next sections describe when and how you can carry out these functions.

View the Error Message

In Figure 2, click on the show BDoc message errors/receivers icon to see
BDoc State
I01 I02 I03 I04 T01 F01 F02 F03 F04 F05 E01 E02 E03 E04 E05 E06 E07 O01 D01 R01

the BDoc errors. In the screen that pops up, click on the Errors button to see the list of errors and their descriptions (Figure 3). Then click on the Longtext button to view the information about the cause of the error. For example, if the system has triggered a business partner transfer, you may see the

Received (intermediate state) Written to queued Remote Function Call (qRFC) queue (intermediate state) After qRFC step (intermediate state) BDoc stored before update task (intermediate state) Temporary lack of resources in application layer Rejected (fully processed) Confirmed (fully processed) Set to processed (fully processed) Confirmed (fully processed by all receivers) Information (no processing) Technical error (incomplete) Partially send, receivers have errors BDoc cannot be read from database BDoc validation error Inbound processing failed Outbound processing failed Conversion error Send to receivers (not all have confirmed) To be processed (debug) Retry after temporary error

Table 1

BDoc state errors

Show BDoc message errors/receivers

Show BDoc message trace

Show BDoc object links


Delete BDoc

Show BDoc message classic data

Show BDoc message extension data


Reprocess BDoc

Figure 2 List of BDocs that appear after you execute transaction SMW01


2008 CRM Expert Reproduction prohibited. All rights reserved.

March 2008

error text Pin code missing. This helps you see that this BDoc is stuck because the system encountered a missing pin code when it created the business partner in the source system. To find the business partner number and to check the pin code field value, you need to display the classic and extension data as explained in the following sections. When you're finished, close the BDoc error segments window to go back to the screen in Figure 2.

see if the same object is available. If the object is not available in the sender system then you can delete this BDoc. If you find the object in the sender system and not in the receiver system, then you confirm that an error occurred during transfer. In this case you need to check the BDoc errors as explained in the previous section. If the object is available in both the sender and receiver systems, then you need to find the detail data the BDoc is carrying. For example, say someone triggers a business partner transfer from ECC to SAP CRM. You found the business partner number by clicking on the classic data icon. In this case you need to check ECC and SAP CRM to ensure that the same business partner is available in both the systems. The extension data shows this information. Display the extension data by clicking on the show extension data icon . Com-

pare this data with the object in receiver system. If you find that the data is the same, then you can delete the BDoc. If the data is not same, then find the BDoc error as explained in the previous section.

Middleware Trace
Sometimes you may face a situation in which the BDoc has errored out and you are unable to find the cause of the error even after clicking on the display BDoc errors icon. In this case the CRM Middleware trace monitor helps you find the error by displaying the trace level and trace program name with the line number. Youll need the assistance of your ABAP developer for this step. Click on the show BDoc message trace icon , use transaction SMWT, or follow menu path BDoc Message>Display>BDoc Message Trace to display the BDoc message trace. All methods lead you to the Middleware Trace screen (Figure 4). The developer uses this information to debug the trace program and find the error. Click on the troubleshooting icon to see the information about troubleshooting this BDoc (Figure 5 on the next page). Here you can find the steps you need to take to resolve the BDoc error.

Show Classic and Extension Data

You can find the business object the BDoc is carrying by clicking on the show BDoc message classic data icon . This shows you the BDoc header, segments, sender, and receiver site with high-level information such as the object name and GUID. After you identify the object, you can check in the sender and receiver systems to

Figure 3 BDoc error segments

Figure 4 Middleware trace monitor with detailed message flow

For group rates on electronic access, call 1-781-751-8799


After you correct the error, click on the . In the screen reprocess BDoc icon that appears, click on the Yes button to reprocess the BDoc. The system reprocesses the BDoc and BDoc status turns green if it successfully processed or it may still remain in same state with a new error. Then you need to follow all the above steps again to find the error until the BDoc is error free.

on the CRM Server for ECC. If an object is not processed correctly within ECC, and the system doesnt return an error condition via BAPI parameters, you must check ECC using transaction SMQ1 (outbound) or SMQ2 (inbound). For example, when you download a product from ECC to SAP CRM, you can find the qRFC entry in ECC transaction SMQ1, which then flows to SAP CRM with the qRFC entry in CRM transaction SMQ2. You display qRFC queues in three steps. For outbound queues, first go to transaction SMQ1 and click on the execute icon to access the qRFC Monitor screen for outbound queues (Figure 6). Select the Queue Name and then click on the display icon to view the entries under that queue with the status and time stamp (Figure 7). You can access additional detailed items by selecting the queue and clicking on the display icon (Figure 8). In this screen you can delete ( ), execute ( ), or debug an entry ( ). For example, when a user triggers a product download from ECC to SAP CRM, you can delete the entry in

Figure 8 (if the product is already available in CRM), execute the download (to send the entries to SAP CRM), or debug the download if it is stuck.

Reduce Data in Inbound and Outbound Queues

Analyzing the errors and reprocessing the BDocs following the processes described earlier reduces data in the CRM Middleware message store and in inbound and outbound queues. The qRFCs then empty the queues. However, you should delete or reorganize the data in certain circumstances, such as successfully processed BDocs or old logs. Depending on the selected trace level in Figure 4, the system writes entries into internal trace tables. You must delete these entries in regular intervals to prevent the tables from becoming too big. Use the following process to reorganize data from traces, logs, and BDocs. First, create a variant of program SMO6_ REORG (reorganization) with transaction SE38. Determine the number of days you

Outbound and Inbound Queues

In the previous section I discussed how to display BDoc messages, identify the errors, and reprocess BDocs. In this section I discuss inbound and outbound qRFC queues. Sometimes you may face a situation in which you trigger an object download, but the object does not transfer to the target system and you cannot find a BDoc error entry using transaction SMW01. In this case you need to check the qRFC queues to find out why the BDoc is stuck in the system. There are inbound and outbound qRFC queues. You can employ the same qRFC outbound queue monitoring that you use

Figure 5 SAP guided procedure to resolve the error screen


2008 CRM Expert Reproduction prohibited. All rights reserved.

March 2008

want to keep the most recent data. The SAP default is variant SAP&_MW_ REORG with seven days. Then schedule the reorganization job by using transaction SM36 or by going to transaction SPRO and following menu path CRM>CRM Middleware and related components> Reorganization>Reorganize Log and Trace Data.
Figure 6 qRFC outbound queue display after executing transaction SMQ1 Pavan Kumar Sunkara is an SAP-certified solution consultant with six years of SAP experience, including five years with SAP CRM and one year with SAP ABAP. He has participated in three Figure 7 qRFC queue entries full lifecycle implementation projects and has expertise in CRM Middleware, Internet Pricing and Configurator (IPC), telesales, and teleservice. He currently works with SITA Corp. as a senior SAP architect. Pavan has worked with major clients from various industries, including hi-tech, manufacturing, and consumer goods. You may contact him via email at Figure 8 Details of each queue entry displayed

For group rates on electronic access, call 1-781-751-8799