Skip to main content

ABAP

SAP: Change request body in BSP response

Submitted by Stefan Barsuhn on

I recently needed to modify the body of an HTTP response in a BSP page. Previously, the request was simply returning a status 403. This was done using request->set_status. So I assumed that I simply had to do request->set_cdata to set the HTML body corresponding to the status. But this was incorrect. 

The correct approach was to use me->write (me referring to the BSP page in the DO_REQUEST method). I know too little about BSP to explain why the request and the BSP page are two different objects.

Tags

SAP: Convert string to multiline table

Submitted by Stefan Barsuhn on

In case you have to deal with text in ERP, the text function modules do not usually allow you to pass a string value. Rather, you have to pass a table that contains your string, split up into multiple lines. The data element of those texts is usually TDLINE and you have to provide some additional information in the table, like object type and format.

Doing this split was actually not very straight-forward because you need to take into account that your (flat) source string may contain line breaks.

Tags

SAP: Transport Report Translations

Submitted by Stefan Barsuhn on

I guess it was the first time that I've translated an SAP report after releasing the code changes to the Q system. But much to my surprise, I wasn't prompted for a transport request when I maintained the translations.

There's a very good article that explains how to transport the translations using transaction SLXT, however what I was really after was how to add those texts to the transport request manually.

Tags

SAP: Get the callstack in ABAP

Submitted by Stefan Barsuhn on

To get the callstack in ABAP, simply call the following line:

DATA(lt_callstack) = cl_abap_get_call_stack=>format_call_stack_with_struct( cl_abap_get_call_stack=>get_call_stack( ) ).

Then you can access the callstack the same way you see it in the debugger, e.g. the name of the program will be in lt_callstack-progname.

Tags

SAP CRM: BPATH - debugging relation traversal

Submitted by Stefan Barsuhn on

Quick note: if you're trying to find out what's going on with your BPATH statement and you want to debug the traversal thereof, the central entrypoint is method CL_WCF_BPATH_PARSER=>STATUSMACHINE. This splits the string and acts on the segments.

Method CL_WCF_BPATH_PARSER=>PROCESS_ACTION is then called to delegate processing of the different segment types to different methods.

Tags

SAP CRM: How order attachments are stored

Submitted by Stefan Barsuhn on

First off, attachments are completely independent from the rest of the transaction. As soon as you add the attachment, it's saved on the DB - no need to save the transaction.

If you're looking for standard source code how to add attachments to an object, set a breakpoint in CL_CRM_DOCUMENTS=>CREATE_WITH_TABLE and upload an attachment. (CL_CRM_BSP_CM_CONTROL=>CREATE_DOCUMENT contains some useful methods to fill the parameters.)

Once the attachment is saved, you can find it in the following tables:

Tags