Showing posts with label SAP. Show all posts
Showing posts with label SAP. Show all posts

Wednesday, 24 September 2025

Consuming EUDR Webservices from SAP ECC

  • There are number of us who're still stuck in the old SAP ECC or S/4 Hana on Premise and yet to move into Private or Public Cloud. A recent regulation in Europe requires us to implement tracebility on products produced by our plants. A requirement requires us to automatically submit the Due Diligent Statement (DDS) to EUDR website to compliance with the EUDR. For this, APIs have been developed to do just that, submitting DDS and getting the reference number and verification number. The APIs are available via Webservices, and to implement this, it is not that hard since SAP has automate the generation of consumer proxy and all required objects based on the WSDL available from EUDR. During first few Conformance Test (CF) that I've tested so far, there are few that probably will be helpful to point out: 
  • After you've loaded and generate the WSDL, using SOAMANAGER, you need to configure logical port. This is where you specified the end point, the username/password etc. In the first CF, this is the easiest one to just ping the server, sending hello in the payload with the correct cridential and header. However, for me, this is not a straight forward thing. 
    1. In SOAMANAGER, while creating logical port, you need to create logical port with "WSDL based configuration with template", and for the template, you need to use the "WSSE_USERNAMETOKEN". This will make the username/password appear in the next step. You need to use your username and authentication key you've created in the system (for testing, we need to get it from acceptance system). Finish the rest and save/activate the logical port. 
    2. While testing the generated class and sending the "hello" in the payload for CF1, I found out that SAP is sending a password and not a password digest as required by EUDR server. From my almost full day of debugging and trying so many options, I finally said that there will be no way that we could configure SAP to send a password digest, so at the end, I do what most of us trying not to do... implicit enhancement! 
    3. The implicit enhancement to Class CL_WSSE_FT_OUT_CFG and method GET_ST_CFG_711. At the end of the method, I put the following codes (this will trigger the passworddigest).   
     IF lf_supp_tk_type = co_t_type_unt.
     DATA(lv_soapaction) = to_upper( get_cfg_value( name = tsrtp_f_bdg_action ) ).            IF lv_soapaction CS 'EUDR' AND unt_st_cfg-digest_type IS INITIAL.                      unt_st_cfg-digest_type = abap_true.
     ENDIF.

          ENDIF.

  • I'm using the SOAPAction field since it has EUDR defined there in the WSDL and I don't want the enhancement gets triggered by other consumer proxy that doesn't have the same requirement for the authentication method. 2. There is also a requirement in the API for us to send a custom tag in the SOAP header. We need to add <v4:WebServiceClientId>eudr-test</v4:WebServiceClientId>  in the SOAP header. The only way to do this is in ABAP, when you call your proxy, you need to inject this custom tag to the header. I managed to do this using the following codes:
            DATA: lr_xml_document TYPE REF TO if_ixml_document,

          lr_xml_element  TYPE REF TO if_ixml_element.

    TRY.
        DATA(lo_ws_header) = CAST if_wsprotocol_ws_header( mr_interface->get_protocol( if_wsprotocol=>ws_header ) ).
      CATCH cx_ai_system_fault.
        RETURN.
      CATCH cx_ai_application_fault.
        RETURN.
    ENDTRY.

    CONCATENATE
      '<env:Header>'
      '<v4:WebServiceClientId xmlns:v4="http://ec.europa.eu/sanco/tracesnt/base/v4">'
      client_id
      '</v4:WebServiceClientId>'
      '</env:Header>' INTO DATA(lv_header).

    DATA(lv_xheader) = cl_proxy_service=>cstring2xstring( lv_header ).

    CALL FUNCTION 'SDIXML_XML_TO_DOM'
      EXPORTING
        xml      = lv_xheader
      IMPORTING
        document = lr_xml_document
      EXCEPTIONS
        OTHERS   = 0.

    DATA(lr_xml_root) = lr_xml_document->get_root_element( ).
    lr_xml_element ?= lr_xml_root->get_first_child( ).

    WHILE NOT lr_xml_element IS INITIAL.
      DATA(l_name) = lr_xml_element->get_name( ).
      DATA(l_namespace) = lr_xml_element->get_namespace_uri( ).
      lo_ws_header->set_request_header(
                  name      = l_name
                  namespace = l_namespace
                  dom       = lr_xml_element ).
      lr_xml_element ?= lr_xml_element->get_next( ).
    ENDWHILE.


  • The next that I found during the CF2 is, I need to send the geojson and this needs to be in base64 and since the xsd refered as base64Binary, the geojson code needs only be converted from the JSON to xstring. No further process needed, SAP will convert it to base64 automatically during the XML creation. 

I will update the blog as and when I find new things. Till then have fun!!!

Thursday, 25 June 2020

Debugging error from VF01

Ever wonder what the easiest way to debug error coming out from VF01? Well, you could try creating watchpoint by checking SYS-MSGID = 'VF' but the easiest is to place a session breakpoint in subroutine VBFS_HINZUFUEGEN which can be found in INCLUDE LV60AA98.




All errors found in the log will need to go through the above routine. Hope this helps! I've been enjoying doing this stuff for more than 20 years! Hope you too! :)

Wednesday, 12 June 2019

Debugging SAP ERMS rules

There probably many CRM implementations which use ERMS, I've come through few requests on how to debug the auto response given by ERMS when CRM receives an inbound email.

SAP provides a tool which you could use to debug this auto response rules. The transaction CRM_ERMS_LOGGING is very helpful. But before we could use this transaction, we need to know the work item ID.

Anyway, here are the steps I used in my debugging:

1. Use SOST, find the response that was sent out, note the date/time
2. Use SWIA, this will return you with work item ID, fill in the time period based on (1) and the task = TS00207915 (ERMS service manager)
3. Put a break point at your auto response implementation
4. Use CRM_ERMS_LOGGING, enter the work item ID and un-tick "Do not execute actions"
5. Execute and you'll be brought to the break point you left in (3)



Tuesday, 19 February 2019

Retrieving older version of sapscript

As you may have come across, there is no versioning available for sapscript in SAP (at least until SAP ECC6, no idea if newer one has it). So is there a way to retrieve your old version?

Simple and straight answer will be, NO!

Workaround? Probably there is. Here is what I've done to work around this:

1. Use SE03 to find the the last good transport for the sapscript.
2. Use STMS_IMPORT to import the previous transport into your QA or Sandbox.
2.1 Extras - Other Requests - Add
2.2 Put transport request, client and click on transport again.
3. Download the sapscript form using RSTXSCRP to your local PC.

Good luck!

Thursday, 1 March 2018

CRM middleware - Debugging incoming BUPA _MAIN/BUPA_REL

Instead of stopping the inbound queue to enable debugging, there is another method which hasn't been documented well.

In the BUPA_CONV_EI2BAPI function module, there is the following code:



This will enable us about 30 seconds to enable debugging from SM50.

Thursday, 14 December 2017

SAP HR Programming?

It has been a while since I touched SAP HR/Payroll, the last time I had touch it was back in 2004 when doing a contracting for a client in St Helens, UK. I had prepared a hand-over document when I left the project and it seems to be uploaded everywhere including in the scribed website. Anyhow, to preserve this further, I'm uploading it to my google drive and linked it here.

SAP HR Programming - Handover Document

Wednesday, 4 October 2017

DMEE - Why copying a standard to bespoke DMEE tree will give different output?

I was faced with this question yesterday and it seems that few payment DMEEs will result in different output when copied into a bespoke Z* or Y* tree. Found out that some of these DMEEs have BADI implemented for them and changing the final file output according to the specific DMEE tree. So, for those who're looking for a reason why your bespoke output file doesn't match the original, do check those available BADI under *DMEE*.

Example that I did yesterday was a copied version of DK_PAYMUL_DOMESTIC. The final file has UNA header as UNA:+,? '. As much as I tried to put a constant in the DMEE tree on a bespoke copy, it won't get copied over to the output file. Found out that there is BADI implemented for that particular DMEE tree, under DMEE_BADI_01 with implementation name DMEE_DK_BADI_01. Copied that and add my bespoke DMEE into the filter and wallah, the output file matches the original.

Hope the above helps those who're stuck wondering why your bespoke copied version won't give the same output result as the standard one.

Tuesday, 4 April 2017

Revert Smartforms / Sapscript editor from MS-Word

I have no idea if this is ECC 6 only feature but I've just upgraded my Office to 2016 and when I get into the smartforms, I couldn't display the text normally. It has an informational text saying "Use the full screen text editor". To change this back to the normal text editor, just run RSCPSETEDITOR ABAP and untick the SAPScript & Smartforms from the selection and activate. This will revert back your default editor.


Monday, 18 January 2016

Debugging DMEE

I've come across many posting on the Internet (via google search), people asking on how to debug a DMEE for payment program. One of the few suggestion was to create a user exit just before the node that we would like to debug and put our breakpoint there. It seems that SAP has built-in this feature without needing us to create a user exit (available in ECC 6, have no idea if this is available on prior releases). Here is how you can put your breakpoint without any coding.

1. Display your DMEE tree using transaction: DMEE_DEBUG.


2. Click on the node that you would like to debug.
3. Go to conditions tab, you could see the Set Breakpoint button. Click to set.



4. Run the SAPFPAYM and specified the payment run date/id, payment format etc. SAP will stop at the node which you point your breakpoint at, as in 2.
5. To remove your breakpoint, just run the DMEE_DEBUG again, there is an option to delete all own breakpoints or all.

Wednesday, 22 April 2015

SAP - Creating customer with multiple company codes using IDOC - Message type = DEBMAS

I had a hard time to make this thing working, replicating customer from CRM and extending the company codes to more than one. The standard CRM -> R/3 won't have a company code and some of the information available during the replication. However this can be added in few places, one of them is using BTE (transaction FIBF->Infosystem P/S), event DE_BALE. We can add our own entries into the CT_IDOC_DATA or manipulate the entries.


To get the multiple company codes to work, it seems that the sequence of segments in the CT_IDOC_DATA is important. I was reading the problem found here:  http://scn.sap.com/thread/3257644 which says that someone had the same problem as me, "Fill all required fields " kind of error.  It took me few hours replicating the sequence, trials and errors and found out that the sequence of segment in CT_IDOC_DATA is important. I couldn't get pass the error if I have the E1KNB1M segment (and it's child segments) earlier than the E1KNVVM segment. Moving the E1KNB1M segment to the end seems to solve my problem. So, if you've problem with your DEBMAS IDOC, trying to create multiple company codes for the customer, try move the segments around, best is to follow the sequence found in the DEBMAS which is:





Friday, 29 August 2014

Activating objects in note outside SNOTE

When implementing SAP notes via SNOTE, we do sometime faced a problem in activating an object due especially those ENHS & INTF where those two types need to be activated first. We can go to SE80 and find inactive objects or the easiest, use SCWB_NOTE_ACTIVATE ABAP to activate the note.

Wednesday, 11 July 2012

SAP CRM Business Partner - Middleware debug

Had a problem with debugging the BP middleware from CRM to ECC and found the following answer in SDN:

  • Put a break point in FM SMW3_MFLOW_UPDATETASKBDOC. 
  • Create a BP and before save type /h to activate debug, mark update debugging option. 
  • When stops in FM SMW3_MFLOW_UPDATETASKBDOC you must be sure to set header-dbgmode = 'X' this will make the bdoc stay stopped in SMW01. 
  • Go to SMW01 and type /h and process the bdoc. Put a break in FM CRM_UPLOAD_AFTER_MAP_HANDLER and be sure to change LV_SYNCHRON = 'X' this will allow you to connect in ECC. 
  • Put a break-point in the "CALL TRANSACTION" command. Change the mode of call transaction and you be able to debug XD* update.
NOTE: to check/resubmit BP from CRM to ECC, use txn: CRMM_BUPA_MAP


Monday, 14 February 2011

SAP/ABAP - external debugging/breakpoint gone haywire

Have you come across an external debugging gone haywire? You tried so many times trying to put in a external breakpoints but your BSP code never stop at your breakpoints? Somehow, I've experienced this too many times while debugging my BSP codes and found that the external debugging table gone haywire .. searching OSS note found a note with a way to remove these haywire breakpoints .. run RSBREAKPOINTS and remove whatever you've there. This should solve your problem..

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.

Tuesday, 17 November 2009

CRM: Copying attachments from service ticket to follow up document

I've got another request which I hope will be easy to implement. Copying all attachments from a service ticket to a follow up document. Hint: CL_CRM_DOCUMENTS.

To get all attachments:

CL_CRM_DOCUMENTS=>GET_INFO
Supply BUSINESS_OBJECT (instid = order's GUID, typeid = order's object_type, catid = 'BO'

To copy to another business object:

CL_CRM_DOCUMENTS=>COPY
Supply BUSINESS_OBJECT & NEW_BUSINESS_OBJECT

It seems that we don't need to use GET_INFO to be able to use the COPY function to copy all documents from the original service ticket to the follow up document. This has yet to be proven by me.. I'll implement it tomorrow and update this blog again.

Update 1: The COPY method is spot on! No further processing needs to be done.

Thursday, 12 November 2009

ABAP: Once in a blue moon..

Yup, once in a blue moon, you'll get a kind of weird requirement to work on. And today, I'm getting one too, adding a serial number to an order which originally created from CRM.

In the first place, this is all bespoke, so, standard middleware wouldn't work. The serial number is passed through CRM order in a customer field and left out when the middleware is called in. What I need is to move this serial number over to R/3 and update the batch number too, in the order!!! Easy does it? Nope!!! But there is a way!

1. In CRM, there is a BDOC exchange BADI which I could use to transfer the serial number over to R/3, the BADI is CRM_DATAEXCHANGE_BADI, use the CRM_DATAEXCH_AFTER_BAPI_FILL method to fill in missing information. I need to enhance the BAPISDITM structure to add this new serial number field.

2. On the R/3 receiving end, thing doesn't seem to be that simple. The BAPI_SALESDOCU_PROXY_UPLOAD doesn't have BADI that I could use to transfer these fields from CRM but, yes, there always be a but. There is BTE available which I could use. BTE/Process 00501020/00501021 could be use to transfer some missing information from CRM to R/3, batch number could be assigned here, no problem. I need to enhance the BAPISDITM here too and probably the VBAPKOM structure too so I could pass this to the final user exit which is, yes, to assign this serial number to the order.

3. Now, how the heck am I going to update this serial number into the order? I have never done this before, I've done updating serials into delivery document but not to an order document. This yet to be tested but this URL seems to be promising, will try this one out:

https://forums.sdn.sap.com:443/thread.jspa?threadID=1470413

Two function modules described at the end of the thread there: IWOL_WV_ADD_OBJECTS & IWOL_WV_POST_OBJECT_LIST.

Will try this and see if I could get it to work! Wish me luck!

Update 1: Success!! Got it to work in less than a day .. couldn't pass the vbapkom to the final stage so I need to use an ABAP memory to pass the final table into the final user exit before I could post it. But somehow, the serial isn't get copied to a delivery document, no idea why, someone needs to fix this for sure. Functional problem :)

Update 2: A small hitch, after they fixed the config, a short dump occurs when creating a delivery. Probably something has to do with the serial counter at VBAP. Need to take a look into this..

Update 3: Scrapped everything on the last part, doesn't seem to work!!! Yes, I could get the serial into the order but as update no 2, I have problem when creating delivery document. It wasn't the serial counter but the object type in OBJK. So, I've implemented this using a new function module SERNR_ADD_TO_AU. I added this in userexit_save_document_prepare instead. I've no problem copying the serial number into the delivery document now.

Consuming EUDR Webservices from SAP ECC

There are number of us who're still stuck in the old SAP ECC or S/4 Hana on Premise and yet to move into Private or Public Cloud. A rece...