cancel
Showing results for 
Search instead for 
Did you mean: 

BADI /SAPAPO/AM_ALERTLIST - How to fill values in new field catalogue

Former Member
0 Kudos

Hi,

I need some help for passing values into the field Catalog of an ALERT Monitor.

The requirement is to add new fields in the ALERT Monitor and then populate them with values form the PRODUCT view.

I have implemented method MODIFY_ALERTLIST of BADI /SAPAPO/AM_ALERTLIST. I am able to add the new columns but I am unable to add the values. Actually while debugging i found that even though the NEW values are going into the table T_ALERTS, but the space between the New Added values and the original value is HUGE. Therefore when the Field Catalog is displayed in the Alert Monitor, the NEW Values are not shown.

I am attaching my Code

DATA: l_table_ref TYPE REF TO data,

l_table_ref_1 TYPE REF TO data,

l_fieldcat_str TYPE /sapapo/am_aot_fieldcat_str,

ls_fieldcat TYPE LINE OF lvc_t_fcat,

ls_t_fieldcat LIKE LINE OF t_fieldcat,

l_alert_str TYPE LINE OF /sapapo/alert_tab,

l_str_ref TYPE REF TO data,

l_str_ref_1 TYPE REF TO data.

FIELD-SYMBOLS: <aot_tab> TYPE STANDARD TABLE,

<aot_tab_1> TYPE STANDARD TABLE,

<alert_str> TYPE /sapapo/alert_str,

<aot_str> TYPE ANY,

<alert_str1> TYPE c,

<alert_str_uc> TYPE c.

FIELD-SYMBOLS: <zat103> TYPE c. "ANY.

DATA : l_col_pos TYPE i,

gv_entries TYPE i,

xlength TYPE i.

FIELD-SYMBOLS : <info> TYPE ANY,

<aot_str1> TYPE ANY.

DATA olen1 TYPE i.

DATA: t_pegid TYPE STANDARD TABLE OF /sapapo/amopegid_tab,

t_ordid TYPE STANDARD TABLE OF /sapapo/amoordid_tab.

CLEAR: l_alert_str,

l_table_ref ,

l_table_ref_1 ,

l_fieldcat_str ,

ls_fieldcat ,

ls_t_fieldcat ,

l_str_ref .

.

*Add new column

READ TABLE t_fieldcat INTO ls_t_fieldcat INDEX 1.

DATA: x1 TYPE lvc_t_fcat,

y1 LIKE LINE OF x1.

x1 = ls_t_fieldcat-fieldcat.

LOOP AT x1 INTO y1 WHERE reptext NE space.

CHECK y1-fieldname NE 'DELIVERY_DATE'.

xlength = xlength + y1-intlen.

ENDLOOP.

DESCRIBE TABLE x1 LINES gv_entries.

  • Appending Delivery Date

ls_fieldcat-col_pos = gv_entries + 1.

ls_fieldcat-fieldname = 'DELIVERY_DATE'.

ls_fieldcat-ifieldname = 'DELIVERY_DATE'.

ls_fieldcat-tabname = '1'.

ls_fieldcat-seltext = 'Delivery Date'.

ls_fieldcat-outputlen = '10'.

  • ls_fieldcat-rollname = '/SAPAPO/DELIVERY_DATE' . "'DATS'.

ls_fieldcat-domname = '/SAPAPO/CHAR20'."'/SAPAPO/DATUM'.

ls_fieldcat-coltext = 'Delivery Date'.

APPEND ls_fieldcat TO ls_t_fieldcat-fieldcat.

  • Appending Start Date

ls_fieldcat-col_pos = gv_entries + 2.

ls_fieldcat-fieldname = 'STARTDAT'.

ls_fieldcat-tabname = '1'.

ls_fieldcat-seltext = 'Start Date'.

ls_fieldcat-outputlen = '10'.

ls_fieldcat-rollname = 'DATS'.

ls_fieldcat-domname = '/SAPAPO/DATUM'.

ls_fieldcat-coltext = 'Start Date'.

APPEND ls_fieldcat TO ls_t_fieldcat-fieldcat.

*

  • Appending Required Shelf Life Date

ls_fieldcat-col_pos = gv_entries + 3.

ls_fieldcat-fieldname = 'SL_MIN_DAT'.

ls_fieldcat-tabname = '1'.

ls_fieldcat-seltext = 'Req.SL dte'.

ls_fieldcat-outputlen = '10'.

ls_fieldcat-rollname = 'DATS'.

ls_fieldcat-domname = '/SAPAPO/DATUM'.

ls_fieldcat-coltext = 'Req.SL dte'.

APPEND ls_fieldcat TO ls_t_fieldcat-fieldcat.

  • Appending Shelf Life Date/Required Maximum Shelf life Date

ls_fieldcat-col_pos = gv_entries + 4.

ls_fieldcat-fieldname = 'SL_MAX_DAT'.

ls_fieldcat-tabname = '1'.

ls_fieldcat-seltext = 'SL Date 2'.

ls_fieldcat-outputlen = '10'.

ls_fieldcat-rollname = 'DATS'.

ls_fieldcat-domname = '/SAPAPO/DATUM'.

ls_fieldcat-coltext = 'SL Date 2'.

APPEND ls_fieldcat TO ls_t_fieldcat-fieldcat.

  • Appending (Availability/Requirements) Date of a Schedule Line

ls_fieldcat-col_pos = gv_entries + 5.

ls_fieldcat-fieldname = 'AVL_REQ_DATE'.

ls_fieldcat-tabname = '1'.

ls_fieldcat-seltext = 'Schedule Date'.

ls_fieldcat-outputlen = '10'.

ls_fieldcat-rollname = 'DATS'.

ls_fieldcat-domname = '/SAPAPO/DATUM'.

ls_fieldcat-coltext = 'Schedule Date'.

APPEND ls_fieldcat TO ls_t_fieldcat-fieldcat.

  • Appending Req Date/ Shipment end date

ls_fieldcat-col_pos = gv_entries + 6.

ls_fieldcat-fieldname = 'SHIP_MAX_DATE'.

ls_fieldcat-tabname = '1'.

ls_fieldcat-seltext = 'Req Date/ Shipment end date'.

ls_fieldcat-outputlen = '10'.

ls_fieldcat-rollname = 'DATS'.

ls_fieldcat-domname = '/SAPAPO/DATUM'.

ls_fieldcat-coltext = 'Req Date/ Shipment end date'.

APPEND ls_fieldcat TO ls_t_fieldcat-fieldcat.

  • Appending Expected Grading Date

ls_fieldcat-col_pos = gv_entries + 7.

ls_fieldcat-fieldname = 'GRAD_DATE'.

ls_fieldcat-tabname = '1'.

ls_fieldcat-seltext = 'Expected Grading Date'.

ls_fieldcat-outputlen = '10'.

ls_fieldcat-rollname = 'DATS'.

ls_fieldcat-domname = '/SAPAPO/DATUM'.

ls_fieldcat-coltext = 'Expected Grading Date'.

APPEND ls_fieldcat TO ls_t_fieldcat-fieldcat.

  • Appending Available Date

ls_fieldcat-col_pos = gv_entries + 8.

ls_fieldcat-fieldname = 'AVAIL_DATE'.

ls_fieldcat-tabname = '1'.

ls_fieldcat-seltext = 'Available Date'.

ls_fieldcat-outputlen = '10'.

ls_fieldcat-rollname = 'DATS'.

ls_fieldcat-domname = '/SAPAPO/DATUM'.

ls_fieldcat-coltext = 'Available Date'.

APPEND ls_fieldcat TO ls_t_fieldcat-fieldcat.

MODIFY TABLE t_fieldcat FROM ls_t_fieldcat.

DATA lvc_t_fcat TYPE lvc_t_fcat.

*CODE FOR ADDING THE NEW VALUES*

************************************************************************

  • ASSIGN Alert Structure to Field Symbols for Unicode

ASSIGN COMPONENT 0 OF STRUCTURE l_alert_str

TO <alert_str> CASTING.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = ls_t_fieldcat-fieldcat

IMPORTING

ep_table = l_table_ref.

*assign dynamic structure

ASSIGN l_table_ref->* TO <aot_tab>.

CREATE DATA l_str_ref LIKE LINE OF <aot_tab>.

ASSIGN l_str_ref->* TO <aot_str>.

ASSIGN l_str_ref->* TO <alert_str_uc> CASTING.

LOOP AT t_alerts INTO l_alert_str.

  • READ TABLE t_fieldcat WITH KEY aot = l_alert_str-aot

  • INTO l_fieldcat_str.

*

  • CALL FUNCTION '/SAPAPO/ATAB_FIELDCAT_GET'

  • EXPORTING

  • aot = l_fieldcat_str-aot

  • mview = l_fieldcat_str-mview

  • IMPORTING

  • table_ref = l_table_ref

  • t_fieldcat = lvc_t_fcat.

ASSIGN l_alert_str TO <alert_str>.

*copy alert to aot-specific structure

MOVE <alert_str>-info TO <alert_str_uc>.

*Write this code inside the loop

ASSIGN COMPONENT 'DELIVERY_DATE' OF STRUCTURE <aot_str> TO <zat103>. "CASTING.

IF sy-subrc = 0.

CLEAR <zat103>.

*Fetch ur own custom value and move to the field symbol. This

*dynamically populates ur structure.

<zat103> = '22.11.1999'.

ENDIF.

ASSIGN COMPONENT 'STARTDAT' OF STRUCTURE <aot_str> TO <zat103> CASTING.

IF sy-subrc = 0.

CLEAR <zat103>.

*Fetch ur own custom value and move to the field symbol. This

*dynamically populates ur structure.

<zat103> = '22.11.1999'.

ENDIF.

ASSIGN COMPONENT 'SL_MIN_DAT' OF STRUCTURE <aot_str> TO <zat103> CASTING.

IF sy-subrc = 0.

CLEAR <zat103>.

*Fetch ur own custom value and move to the field symbol. This

*dynamically populates ur structure.

<zat103> = '22.11.1999'.

ENDIF.

ASSIGN COMPONENT 'SL_MAX_DAT' OF STRUCTURE <aot_str> TO <zat103> CASTING.

IF sy-subrc = 0.

CLEAR <zat103>.

*Fetch ur own custom value and move to the field symbol. This

*dynamically populates ur structure.

<zat103> = '22.11.1999'.

ENDIF.

ASSIGN COMPONENT 'AVL_REQ_DATE' OF STRUCTURE <aot_str> TO <zat103> CASTING.

IF sy-subrc = 0.

CLEAR <zat103>.

*Fetch ur own custom value and move to the field symbol. This

*dynamically populates ur structure.

<zat103> = '22.11.1999'.

ENDIF.

ASSIGN COMPONENT 'SHIP_MAX_DATE' OF STRUCTURE <aot_str> TO <zat103> CASTING.

IF sy-subrc = 0.

CLEAR <zat103>.

<zat103> = '22.11.1999'.

ENDIF.

ASSIGN COMPONENT 'GRAD_DATE' OF STRUCTURE <aot_str> TO <zat103> CASTING.

IF sy-subrc = 0.

CLEAR <zat103>.

*Fetch ur own custom value and move to the field symbol. This

*dynamically populates ur structure.

<zat103> = '22.11.1999'.

ENDIF.

ASSIGN COMPONENT 'AVAIL_DATE' OF STRUCTURE <aot_str> TO <zat103> CASTING.

IF sy-subrc = 0.

CLEAR <zat103>.

*Fetch ur own custom value and move to the field symbol. This

*dynamically populates ur structure.

<zat103> = '22.11.1999'.

ENDIF.

MOVE <alert_str_uc> TO <alert_str>-info.

MODIFY t_alerts FROM l_alert_str INDEX sy-tabix.

CLEAR : <alert_str>, <alert_str_uc>.

ENDLOOP.

I have even tried Concatenating Values, with that method even though the NEW Values are available but they do not fall under the correct Column.

PLEASE help me out cos I am really Stuck.

Regards

Abhishek Sahi

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Abhishek,

I am struck with the similar problem.

I am not able to populate the new column with the value.

Do you have the solution for it.

Many Thanks!

Parul