on 2020 Nov 25 5:04 PM
Hi, friends.
I've created an Open channel in custom logic: ZOC_SEND_DATA.
I've defined my implementation in (1) Open Channel: Define Implementations.
In (3) Open Channel: Define Global Settings for Execution I've added custom logic.
I want to add to the header of this JSON-file my custom attributes: start_date, end_date.
But when I run Campaign (Exporting Definition works fine) there are no custom fields in JSON-file.
Can anybody help me to figure out what's the problem?
Thanks!
{ "d": {
"Campaign": { some data },
"PackageId": 1,
"ExecutionStartDateTime": "2020-11-25T15:52:17Z",
"ExecutionRunKey": "",
Here should be mine custom fields
"CampaignTargetGroupMembers": [{ some data }]},
DATA: lv_campaign_id TYPE cuan_initiative_id,
lr_oc_header_attribute TYPE REF TO cuan_s_oc_header_attribute,
ls_campaign_root_api TYPE cuan_s_campaign_root_api.
package_size = 100.
READ TABLE header_attributes REFERENCE INTO lr_oc_header_attribute WITH KEY param_name = if_cuan_mkt_orch_constants=>sc_open_channel_header_attr-campaign.
IF sy-subrc = 0.
lv_campaign_id = lr_oc_header_attribute->param_value.
ls_campaign_root_api = cl_cuan_campaign_helper_api=>campaign_root_read( EXPORTING iv_id = lv_campaign_id ).
APPEND VALUE #( param_name = 'START_DATE'
param_value = ls_campaign_root_api-start_date ) TO header_attributes.
APPEND VALUE #( param_name = 'END_DATE'
param_value = ls_campaign_root_api-end_date ) TO header_attributes.
ENDIF.
Request clarification before answering.
Hi Sigy,
It is currently not possible to have the custom header attributes included in the payload at the same level as ExecutionRunKey, Campaign... (refer my previous reply). You could submit a customer influence request for that.
However, the recommendation Cagri gave you will allow for those custom attributes to be added to the Target Group Member data in the payload. Therefore my expectation is that you should see your attributes in the payload within the target group member data. If that is not working, then I would suggest that you open an incident so that it can be investigated further by the support teams.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sigy,
When you say the latest attempt is still not working, what exactly isn't working?
The expectations with the changes you did based on Cagri feedback is that your custom attributes (e.g. START_DATE, END_DATE) are going to be in the payload at the same level as the target group member data. Can you confirm whether that works or not.
As for your initial goal to have the custom header attributes in the payload at the same level as Campaign, ExecutionRunKey...that is currently not possible.
Best regards,
Claude
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Claude,
You're right, I need to add my custom attributes at the same level as ExecutionRunKey, Campaign, etc.
Based on Cagri feedback "The value should be set in 4th badi for this attribute." I've tried to do that & I think I'm wrong.
Regarding "Can you confirm whether that works or not?" it does not work.
Is it possible to solve my issue or not?
Thanks!
Hi Sigy,
Class 3 is not the correct place to put the parameter; please have a look my suggestion below.
This logic is adding the description of the campaign to the header.
(2) Open Channel: Define Parameters for Implementation
APPEND VALUE #( action_parameter = 'ZXXX_CampaignDesc'
action_parameter_name = 'Description'
action_parameter_type = if_cuan_mkt_orch_constants=>action_param_type-string ) TO action_parameters.
(4) Open Channel: Enhance Payload for Data Transfer
DATA lv_campaign type C length 10.
DATA lv_desc type String.
DATA lv_message type String.
DATA ls_param like line of header_attributes.
DATA ls_campaign_root_api TYPE cuan_s_campaign_root_api.
READ TABLE header_attributes ASSIGNING FIELD-SYMBOL(<ls_header_attributes>) " table contains also the action parameters
WITH KEY param_name = 'ZXXX_CampaignDesc'.
IF sy-subrc = 0.
APPEND VALUE #( attribute_id = 'ZXXX_CampaignDesc'
attribute_name = 'Description'
attribute_type = 'Edm.String' ) TO target_group_member_attributes.
DATA(lv_description) = <ls_header_attributes>-param_value. " helper variable, needed in next loop
* ENDIF.
ENDIF.
read table HEADER_ATTRIBUTES assigning FIELD-SYMBOL(<ls_header>) WITH KEY param_name = 'CAMPAIGN'.
if sy-subrc eq 0.
lv_campaign = <ls_header>-param_value.
endif.
ls_campaign_root_api = cl_cuan_campaign_helper_api=>campaign_root_read( EXPORTING iv_id = lv_campaign ).
lv_desc = ls_campaign_root_api-description.
APPEND VALUE #( tg_member_key = <ls_target_group_member_data>-tg_member_key
tg_member_interaction_contact = <ls_target_group_member_data>-tg_member_interaction_contact
tg_member_interaction = <ls_target_group_member_data>-tg_member_interaction
attribute_id = 'ZXXX_CampaignDesc'
attribute_value = lv_desc ) TO target_group_member_data.
cl_ble_trace_writer=>write_info_message( lv_desc ).
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot, Cagri for your feedback.
I don't wanna add custom attributes into "CampaignTargetGroupMembers" tag or into "TargetGroupMemberAttributeData" tag.
My custom attributes should be in the campaign header after the "ExecutionRunKey" attribute.
Take a look at the code, please.
{ "d": {
"Campaign": { some data },
"PackageId": 1,
"ExecutionStartDateTime": "2020-11-25T15:52:17Z",
"ExecutionRunKey": "",
Here should be my custom fields
"CampaignTargetGroupMembers": [{ some data }]}
Hi Sigy,
Then you're right to append the field on the 3rd badi, but you still also need to implement to 4th badi to manipulate the payload. The value should be set in 4th badi for this attribute.
Please append the attribute id and value to the header_attribute in this badi. You can set a constant as an example and check if it works. Then you can develop your logic into it.
Regards,
Cagri
Cagri, I did what you said, but it still doesn't work.
Maybe you know that something additional should be activated or recreated, i.e. Communication arrangements or smth.?
Here's my code in 3 & 4 Class in Open Channel Definition.
DATA: lv_campaign_id TYPE cuan_initiative_id,
lr_oc_header_attribute TYPE REF TO cuan_s_oc_header_attribute,
ls_campaign_root_api TYPE cuan_s_campaign_root_api,
ls_error_messages TYPE hpa_error_messages.
package_size = 100.
check_permission = abap_false.
READ TABLE header_attributes REFERENCE INTO lr_oc_header_attribute WITH KEY param_name = if_cuan_mkt_orch_constants=>sc_open_channel_header_attr-campaign.
IF sy-subrc = 0.
lv_campaign_id = lr_oc_header_attribute->param_value.
ls_campaign_root_api = cl_cuan_campaign_helper_api=>campaign_root_read( EXPORTING iv_id = lv_campaign_id ).
SELECT SINGLE targetgroupuuid, campaign FROM i_mkt_initiative INTO (@DATA(lv_tg_guid),@DATA(lv_campaign_guid)) WHERE campaignid = @lv_campaign_id.
IF lv_tg_guid IS NOT INITIAL.
DATA(lv_tg_id) = cl_cuan_tg_common_api=>conv_root_guid_to_id( iv_tg_guid = lv_tg_guid ).
ENDIF.
APPEND VALUE #( param_name = 'CAMPAIGN_GUID'
param_value = lv_campaign_guid ) TO header_attributes.
APPEND VALUE #( param_name = 'START_DATE'
param_value = ls_campaign_root_api-start_date ) TO header_attributes.
ELSE.
error_occured = abap_true.
ENDIF.
APPEND VALUE #( param_name = 'END_DATE'
param_value = '2020-11-26T09:39:19Z' ) TO header_attributes.
Here's the code in the 4 class.
READ TABLE header_attributes ASSIGNING FIELD-SYMBOL(<ls_header_attributes>) WITH KEY param_name = 'CAMPAIGN_GUID'.
IF sy-subrc = 0.
APPEND VALUE #( attribute_id = 'CAMPAIGN_GUID'
attribute_name = 'Campaign guid'
attribute_type = 'Edm.String' ) TO target_group_member_attributes.
DATA(lv_guid) = <ls_header_attributes>-param_value.
ENDIF.
IF lv_guid IS INITIAL.
lv_guid = 'Dummy GUID'.
ENDIF.
READ TABLE header_attributes ASSIGNING <ls_header_attributes> WITH KEY param_name = 'START_DATE'.
IF sy-subrc = 0.
APPEND VALUE #( attribute_id = 'START_DATE'
attribute_name = 'Start date'
attribute_type = 'Edm.String' ) TO target_group_member_attributes.
DATA(lv_start_date) = <ls_header_attributes>-param_value.
ENDIF.
APPEND VALUE #( attribute_id = 'END_DATE'
attribute_name = 'End date'
attribute_type = 'Edm.String' ) TO target_group_member_attributes.
LOOP AT target_group_member_status ASSIGNING FIELD-SYMBOL(<ls_target_group_member_stat>).
READ TABLE target_group_member_data ASSIGNING FIELD-SYMBOL(<ls_target_group_member_data>) WITH KEY tg_member_key = <ls_target_group_member_stat>-tg_member_key.
CHECK sy-subrc IS INITIAL.
APPEND VALUE #( tg_member_key = <ls_target_group_member_data>-tg_member_key
tg_member_interaction_contact = <ls_target_group_member_data>-tg_member_interaction_contact
tg_member_interaction = <ls_target_group_member_data>-tg_member_interaction
attribute_id = 'CAMPAIGN_GUID'
attribute_value = lv_guid ) TO target_group_member_data.
APPEND VALUE #( tg_member_key = <ls_target_group_member_data>-tg_member_key
tg_member_interaction_contact = <ls_target_group_member_data>-tg_member_interaction_contact
tg_member_interaction = <ls_target_group_member_data>-tg_member_interaction
attribute_id = 'START_DATE'
attribute_value = lv_start_date ) TO target_group_member_data.
APPEND VALUE #( tg_member_key = <ls_target_group_member_data>-tg_member_key
tg_member_interaction_contact = <ls_target_group_member_data>-tg_member_interaction_contact
tg_member_interaction = <ls_target_group_member_data>-tg_member_interaction
attribute_id = 'END_DATE'
attribute_value = '2020-11-26T09:39:19Z' ) TO target_group_member_data.
ENDLOOP.
cl_ble_trace_writer=>write_info_message( lv_guid ).
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.