Skip to Content
avatar image
Former Member

Problem with the control break statement - AT END OF

data : IT_DATA TYPE STANDARD TABLE OF /BIC/OH0SPA_OHD WITH KEY /B28/S_D1DVOX5 ,

FIELD-SYMBOLS : <ls_data> TYPE any,

SELECT * FROM (c_open_hub) INTO TABLE IT_DATA .

*IF sy-subrc = 0.

*ENDIF.

  • Create the GUID for header

CALL FUNCTION 'GUID_CREATE'

IMPORTING

EV_GUID_32 = LV_GUID.

TRY.

CALL METHOD CL_GDT_CONVERSION=>GUID_OUTBOUND

EXPORTING

IM_GUID_C = LV_GUID

IMPORTING

EX_VALUE = LV_UUID.

CATCH CX_GDT_CONVERSION INTO go_exc .

gv_text = go_exc->get_text( ).

  • Application log for errors

IF gv_text IS NOT INITIAL.

PERFORM add_msg_to_log CHANGING lt_return.

CALL FUNCTION '/SPA/APPL_LOG'

EXPORTING

LV_OBJECT = '/SPA/APPL'

LV_SUBOBJECT = '/SPA/ESOA'

IT_RETURN = lt_return.

ENDIF.

ENDTRY.

OUTPUT-TRADE_PROMOTION_CRMBULK_CREATE-MESSAGE_HEADER-ID-CONTENT = LV_GUID.

OUTPUT-TRADE_PROMOTION_CRMBULK_CREATE-MESSAGE_HEADER-UUID-CONTENT = LV_UUID.

SELECT * FROM DD03T INTO TABLE lt_dd03t WHERE TABNAME = c_open_hub AND DDLANGUAGE = 'E' AND AS4LOCAL = 'A'.

*IF sy-subrc = 0.

*ENDIF.

  • Sort the delta table

SORT it_data.

  • populate the output structure

LOOP AT IT_DATA ASSIGNING <ls_data>.

READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_keyfigures.

ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_keyfigures>.

READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_signdata.

ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_signdata>.

READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_bbtype.

ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_bbtype>.

READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_customer.

ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_customer>.

READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_product.

ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_product>.

READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_territory.

ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_territory>.

READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_time.

ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_time>.

CASE <l_keyfigures>.

WHEN c_sd.

PERFORM DATE_CALC USING <l_signdata> CHANGING LV_DATE.

ls_period_term-start_date = lv_date.

WHEN c_ed.

PERFORM DATE_CALC USING <l_signdata> CHANGING LV_DATE.

ls_period_term-end_date = lv_date.

WHEN c_uplift.

LS_PRODUCT_KF-ID-CONTENT = c_uplift_qyts.

LS_PRODUCT_KF-VALUE = <l_signdata>.

  • LS_PRODUCT_KF-YEAR = lv_week(4).

  • LS_PRODUCT_KF-CALENDAR_PERIOD_ORDINAL_NUMBER = lv_week+4.

APPEND LS_PRODUCT_KF TO LT_PRODUCT_KF.

WHEN OTHERS.

  • PERFORM DATE_CALC USING <l_signdata> CHANGING LV_DATE.

  • ls_period_term-start_date = lv_date.

  • Get week

  • CALL FUNCTION 'DATE_GET_WEEK'

  • EXPORTING

  • DATE = LS_PERIOD_TERM-START_DATE

  • IMPORTING

  • WEEK = LV_WEEK.

  • append Keyfigure

LS_PRODUCT_KF-ID-CONTENT = <l_keyfigures> .

LS_PRODUCT_KF-VALUE = <l_signdata>.

  • LS_PRODUCT_KF-YEAR = lv_week(4).

  • LS_PRODUCT_KF-CALENDAR_PERIOD_ORDINAL_NUMBER = lv_week+4.

APPEND LS_PRODUCT_KF TO LT_PRODUCT_KF.

  • append tradespend

SELECT SINGLE * FROM /SPA/SPEND_MAP INTO CORRESPONDING FIELDS OF LV_/SPA/SPEND_MAP

WHERE KEY_FIGURE = <l_keyfigures>.

IF sy-subrc = 0.

LS_TRADE_SPEND-TYPE_CODE-CONTENT = LV_/SPA/SPEND_MAP-SPEND_TYPE.

LS_TRADE_SPEND-CATEGORY_CODE-CONTENT = LV_/SPA/SPEND_MAP-SPEND_CATEGORY.

LS_TRADE_SPEND-METHOD_CODE-CONTENT = LV_/SPA/SPEND_MAP-SPEND_METHOD.

APPEND LS_TRADE_SPEND TO LT_TRADE_SPEND.

else.

lv_flg = 'X'.

ENDIF.

ENDCASE.

AT END OF /B28/S_D1DVOX5. "

SELECT SINGLE * FROM /SPA/SO_TER_MAP INTO LS_/SPA/SO_TER_MAP WHERE TERRITORY = <l_territory>.

IF sy-subrc = 0 AND lv_flg IS INITIAL.

  • Create the GUID for TP's

CALL FUNCTION 'GUID_CREATE'

IMPORTING

EV_GUID_32 = LV_GUID_MESSAGE.

TRY.

CALL METHOD CL_GDT_CONVERSION=>GUID_OUTBOUND

EXPORTING

IM_GUID_C = LV_GUID_MESSAGE

IMPORTING

EX_VALUE = LV_UUID_MESSAGE.

CATCH CX_GDT_CONVERSION .

ENDTRY.

  • populate the product

LS_PRODUCT-ID-CONTENT = <l_product>.

LS_CUSTOMER-ID-CONTENT = '300022'.

LS_CUSTOMER-ROLE_CODE = '00000105'.

LS_PRODUCT-KEY_FIGURE = LT_PRODUCT_KF.

APPEND LS_PRODUCT TO LT_PRODUCT.

APPEND LS_CUSTOMER TO LT_CUSTOMER.

APPEND LS_DESCRIPTION TO LT_DESCRIPTION.

APPEND LS_PERIOD_TERM TO LT_PERIOD_TERM.

LS_TRADE_PROMOTION-TRADE_PROMOTION-SALES_AREA-ORGANISATIONAL_CENTRE_ID = LS_/SPA/SO_TER_MAP-SALES__ORG.

LS_TRADE_PROMOTION-TRADE_PROMOTION-SALES_AREA-DISTRIBUTION_CHANNEL_CODE-CONTENT = LS_/SPA/SO_TER_MAP-DIST_CHANNEL.

LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_ACCOUNT-CUSTOMER_INTERNAL_ID = <l_customer>.

LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_PROFILE_GROUP_CODE-CONTENT = '4TPM'.

LS_TRADE_PROMOTION-TRADE_PROMOTION-TYPE_CODE-CONTENT = 'Z002'.

LS_TRADE_PROMOTION-TRADE_PROMOTION-UPLIFT_ACTIVE_INDICATOR = 'X'.

LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_INFORMATION-MARKETING_PROJECT_PLANNING_PRO = '5'.

LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_INFORMATION-CALENDAR_UNIT_CODE = 'WEE'.

LS_TRADE_PROMOTION-TRADE_PROMOTION-TRADE_SPEND = LT_TRADE_SPEND.

LS_TRADE_PROMOTION-TRADE_PROMOTION-PARTY = LT_CUSTOMER.

LS_TRADE_PROMOTION-TRADE_PROMOTION-DESCRIPTION = LT_DESCRIPTION.

LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_INFORMATION-PRODUCT = LT_PRODUCT.

LS_TRADE_PROMOTION-TRADE_PROMOTION-PERIOD_TERM = LT_PERIOD_TERM.

LS_TRADE_PROMOTION-MESSAGE_HEADER-ID-CONTENT = LV_GUID_MESSAGE.

LS_TRADE_PROMOTION-MESSAGE_HEADER-UUID-CONTENT = LV_UUID_MESSAGE.

LS_/SPA/REPORT_TAB-SPA_TP_ID = <l_bbtype>.

LS_/SPA/REPORT_TAB-MESSAGE_ID = LV_GUID_MESSAGE.

LS_/SPA/REPORT_TAB-CREATE_DATE = SY-DATUM.

INSERT /SPA/REPORT_TAB FROM LS_/SPA/REPORT_TAB.

APPEND LS_TRADE_PROMOTION TO LT_TRADE_PROMOTION.

OUTPUT-TRADE_PROMOTION_CRMBULK_CREATE-TRADE_PROMOTION_CRMCREATE_REQU = LT_TRADE_PROMOTION.

CLEAR : LT_DESCRIPTION, LT_PERIOD_TERM,LT_CUSTOMER, LT_PRODUCT, LT_PRODUCT_KF, LT_TRADE_SPEND,LS_/SPA/HEADER_TAB.

ENDIF.

CLEAR lv_flg .

ENDAT.

ENDLOOP.

My problem is AT-END OF STATEMENT IS executing for each and every record of same /B28/S_D1DVOX5.

Please help me from this problem

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jun 22, 2010 at 09:42 AM

    Hello,

    First of all to know clearly about AT END.

    Let's say In IT_DATA fields are F1 F2 F3 /B28/S_D1DVOX5 F5.

    then AT END of /B28/S_D1DVOX5 means for each new value of this field at the end it will trigger.

    Please ensure thet IT_DATA is sorted by this field and then used Control break.

    Thanks,

    Pramod

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 22, 2010 at 09:58 AM

    Hi,

    First condition for using AT END OF is that table must be sorted.I hope you must have done that.

    Then second thing is, this event is triggered if value in any field to the left side of field mentioned changes.

    For example if I have a table with fields f1 f2 f3 f4.

    If I use the statement AT END OF f3.

    In this case event will be triggered even if value in f1 or f2 changes.

    Hope you get the idea.

    Thnaks & Regards,

    Vivek Kumar

    Add comment
    10|10000 characters needed characters exceeded