cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Open Channel Integration - How to add custom attributes to the payload?

former_member355106
Active Participant
1,270

Hi together,

we have implemented the open channel integration to send a csv file via CPI to an external SFTP Server.

The problem is now we have created several fields in the contect "Marketing: Campaign". These fields are shown on the campaign and can be filled out on the UI -> so far so good.

Now we want to add these data also with the payload as meadata to the csv file like shown in the following xml file overview:

There exists the BAdI "(4) Open Channel: Enhance Payload for Data Transfer". In this BAdI there exists the table "TARGET_GROUP_MEMBER_ATTRIBUTES" which is described as: This table contains the meta-data of the transferred data.

How we would enhance this BAdI so our custom attributes are send to within the payload?

BR/

Accepted Solutions (1)

Accepted Solutions (1)

former_member355106
Active Participant
0 Likes

We forgot to put put the filter ID (e.g. ZOC_INI_GOAL) to the BADI. Now it works.

Answers (1)

Answers (1)

former_member226
Employee
Employee

Hi,

BAdI "(4) Open Channel: Enhance Payload for Data Transfer" shall only be used to enhance the payload for Each Target Group member with certain attributes from export definition, But since you want to add the campaign header attribute to message header my recommendation would be to implement "(3) Open Channel: Define Global Settings for Execution" and append the additional custom campaign parameter in "changing Table HEADER_ATTRIBUTES'.

for this purpose you can make a read call to campaign at run time using cl_cuan_campaign_helper_api=>campaign_root_read( EXPORTING iv_id = lv_campaign_id ).

    DATA: lv_campaign_id         TYPE cuan_initiative_id,
          ls_header_Attr         like line of HEADER_ATTRIBUTES,
          ls_campaign_root_api   TYPE cuan_s_campaign_root_api.


    package_size = 20. " change the number of target group members processed in one package and transferred in the odata payload
    CHECK_PERMISSION = abap_false.


    read table HEADER_ATTRIBUTES assigning FIELD-SYMBOL(<fs_head>) WITH KEY param_name = 'CAMPAIGN'.
    if sy-subrc eq 0.
       lv_campaign_id = <fs_head>-param_value.
    endif.


   ls_campaign_root_api = cl_cuan_campaign_helper_api=>campaign_root_read( EXPORTING iv_id = lv_campaign_id ).


    if ls_campaign_root_api-yy1_goal_min is NOT INITIAL.
    clear ls_header_attr.
    ls_header_attr-param_name = 'ZOC_INI_GOAL'.
    ls_header_attr-param_value = ls_campaign_root_api-yy1_goal_min.
    append ls_header_Attr to HEADER_ATTRIBUTES.
    endif.


Thanks

Saurabh

former_member355106
Active Participant
0 Likes

Dear Saurabh,

thank you so much for your reply. We have tried to add the fields to the Output by using BADI "Open Channel: Define Global Settings for Execution” (CUAN_CPG_OPN_CHNL_PRE_PROC)".

The coding right now is as follow:

DATA: lv_campaign_id         TYPE cuan_initiative_id,
          ls_header_attr         LIKE LINE OF header_attributes,
          lv_error_message       LIKE LINE OF error_messages,
          ls_campaign_root_api   TYPE cuan_s_campaign_root_api.


READ TABLE header_attributes ASSIGNING FIELD-SYMBOL(<fs_head>) WITH KEY param_name = 'CAMPAIGN'.
    IF sy-subrc EQ 0.
       lv_campaign_id = <fs_head>-param_value.


       ls_campaign_root_api = cl_cuan_campaign_helper_api=>campaign_root_read( EXPORTING iv_id = lv_campaign_id ).


       CLEAR ls_header_attr.
       ls_header_attr-param_name = 'ZOC_EXPORT_YY1_ANZAHL_PROSPEKTE'.
       ls_header_attr-param_value = ls_campaign_root_api-yy1_anzahl_prospekte_min.
       APPEND ls_header_attr to header_attributes.
    ENDIF.

Unfortunately the field "yy1_anzahl_prospekte_min" is not added to the header of the message. Still we just have the fields of the export definition that are being send.

Could you tell us please, if the "new" attributes have to be pusblished somewhere (?) else as we can not debug the code in the cloud solution. Do you have any more hints for us?

BR/

former_member226
Employee
Employee
0 Likes

I understand the pain of no debug at run time in UI but may be I will also check with product team for this and will come back in case of any input from them about your issue.

Thanks

Saurabh