on 05-05-2006 2:38 PM
Hi,
In the standard SAP module:
Fucntion /SAPAPO/MSDP_SH_MATLOC_LIST there is a routine:
Matloc_get.
Within this there is function call:
CALL FUNCTION '/SAPAPO/DM_MATLOC_GET'.
CALL FUNCTION '/SAPAPO/DM_MATLOC_GET'
EXPORTING
it_matloc_id = lt_matid_locid
iv_vrsioid = lv_version
IMPORTING
et_matloc = lt_matloc
EXCEPTIONS
matloc_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
egal
ENDIF.
The flow of the program after this is:
IF gp_exit IS INITIAL.
CALL METHOD cl_exithandler=>get_instance
EXPORTING
exit_name = '/SAPAPO/SDP_SELECTOR'
null_instance_accepted = seex_false
IMPORTING
act_imp_existing = gv_exit_active_imp
CHANGING
instance = gp_exit.
ENDIF.
IF gv_exit_active_imp = true.
CALL METHOD gp_exit->loc_prod_value_list
EXPORTING
it_selection = it_selection
it_matloc = lt_matloc
it_matkey_tab = lt_matkey
it_mattext = lt_mattxt
it_loc = lt_location
it_loctext = lt_loc_txt
it_field_catalog = ct_alv_fcat
CHANGING
ct_value_list = ct_value_list.
ENDIF.
The problem is with the standard SAP program which does not pick up the material location combination in the internal table ct_value_list based on the user selections in the transaction /sapapo/sdp94 for the planning book.
Has anyone come across this problem before.
cheers
Aveek
Here is the code dump:
Constants
CONSTANTS : lc_quote TYPE char1 VALUE '''', " Quote
lc_rpar TYPE char1 VALUE ')',
lc_lpar TYPE char1 VALUE '(',
lc_eq TYPE char2 VALUE 'EQ', " Equal
lc_bt TYPE char2 VALUE 'BT', " Between
lc_equal TYPE char1 VALUE '=', " Equals sign
lc_noteq TYPE char2 VALUE '<>', " Not equals
" SR 2,742,923
lc_cp TYPE char2 VALUE 'CP', " Compare
lc_between TYPE char7 VALUE 'BETWEEN', " Between
lc_and TYPE char3 VALUE 'AND', " And
lc_or TYPE char2 VALUE 'OR', " Or
lc_parpr TYPE char5 VALUE 'PARPR', " PARPR
lc_prvar TYPE char5 VALUE 'PRVAR', " PRVAR
lc_varid TYPE char5 VALUE 'VARID', " VARID
lc_varct TYPE char5 VALUE 'VARCT', " VARCT
lc_vartx TYPE char5 VALUE 'VARTX', " VARTX
lc_dmoap TYPE char5 VALUE 'DMOAP', " DMOAP
lc_matkl TYPE char5 VALUE 'MATKL', " MATKL
lc_matnr TYPE char5 VALUE 'MATNR', " MATNR
lc_locno TYPE char5 VALUE 'LOCNO', " LOCNO
lc_mktgr TYPE CHAR5 VALUE 'MKTGR', " MKTGR
lc_matdesc TYPE char9 VALUE 'MAT_DESCR', " MATNR DESCR
lc_plansnp TYPE char11 VALUE 'PLANNER_SNP'," PLANNER SNP
lc_locdesc TYPE char9 VALUE 'LOC_DESCR', " LOCTN DESCR
lc_icon TYPE char4 VALUE 'ICON', " ICON
lc_dot TYPE char1 VALUE '.',
Table name
lc_tabname TYPE ddobjname VALUE 'ZD_APO_PRODVAR1'.
*
*
TYPES:
Table structure
ls_table_structure TYPE dfies,
*
Int. table holding field structure
lt_table_structure TYPE STANDARD TABLE OF ls_table_structure
*,
*
Holds entries from MATLOC table
BEGIN OF ls_matloc,
matid TYPE /sapapo/matid, " Product ID
locid TYPE /sapapo/locid, " Location ID
matnr TYPE matnr, " Product
locno TYPE /sapapo/locno, " Location number
END OF ls_matloc,
lt_matloc TYPE STANDARD TABLE OF ls_matloc, " Table type
Holds data from ZD_APO_PRODVAR1
lt_data TYPE STANDARD TABLE OF zd_apo_prodvar1. " Table type
*
Internal tables
DATA :
Int. table with values
lt_values TYPE TABLE OF seahlpres,
Int. table with field info
lt_matkey_tab_tmp TYPE /sapapo/matkey_tab,
lt_field TYPE TABLE OF dfies,
Selected values returned from the F4 FM
lt_return TYPE TABLE OF ddshretval,
Int. table with matkey values
lt_rowindex TYPE TABLE OF /sapapo/matkey,
Int. table with user's selections
lt_user_selections TYPE /sapapo/sh_sel_range_tab,
Int. table with field structure
lt_table_structure TYPE lt_table_structure,
Int. table with prodvar1 values
lt_data TYPE lt_data,
Int. table with matloc entries
lt_matloc TYPE lt_matloc,
lr_matkl TYPE RANGE OF /sapapo/matkl_p,
ls_matkl LIKE LINE OF lr_matkl.
*
Work areas
DATA : ls_field TYPE dfies, " Field info
ls_values TYPE seahlpres, " Field value
ls_matloc TYPE ls_matloc,
ls_data TYPE zd_apo_prodvar1,
ls_table_type TYPE dd02v-tabclass. " Type of the table
*
Variables
*
DATA :
lv_where_condn TYPE string, " Dynamic where condn
lv_where_condn TYPE SYCHAR512, " Dynamic where condn
MOD-1921195.
lv_where_condn TYPE char2000, " Dynamic where condn
**MOD-1921195.
lv_where_condn1 TYPE string,
lv_col_name TYPE string, " Column name
lv_col_name_new TYPE string,
lv_col_value_low TYPE string, " Column value - low
lv_col_value_high TYPE string, " Column value - high
lv_col_option TYPE string, " Column option
lv_col_sign TYPE string, " SR 2,742,923
lv_lines TYPE sytabix, " Number of lines
lv_value_list_ref TYPE REF TO data, " Line of CT_VALUE_LIST
**Ref
lv_xtn TYPE char2,
lv_par TYPE char1 VALUE '(',
lv_flag TYPE flag,
lv_flag_var TYPE flag,
lv_dummymat TYPE matnr,
lv_matid TYPE /sapapo/matid,
lv_tabix TYPE sytabix,
lv_flag_sel TYPE flag,
lv_locid TYPE /sapapo/locid,
*
lr_matnr type range of /sapapo/matnr,
ls_matnr like line of lr_matnr.
*
Field symbols
FIELD-SYMBOLS :
Return value
<lfs_wa_return> TYPE ddshretval,
zd_apo_prodvar1 value
<lfs_data> TYPE zd_apo_prodvar1,
Value to be given to F4 FM
<lfs_values> TYPE seahlpres,
Field info
<lfs_field> TYPE dfies,
Structure with user's selections
<lfs_user_selections> TYPE /sapapo/sh_sel_range_str,
<lfs_user_selections_n> TYPE
*/sapapo/sh_sel_range_str,
field structure
<lfs_table_structure> TYPE ls_table_structure,
Matloc entry
<lfs_matloc> TYPE ls_matloc,
Matkey entry
<lfs_matkey> TYPE /sapapo/matkey,
Loc entry
<lfs_loc> TYPE /sapapo/loc,
Loctext entry
<lfs_loctext> TYPE /sapapo/loct,
Matloc entry
<lfs_matloc_int> TYPE /sapapo/matloc,
CT_VALUE_LIST entry
<lfs_value_list> TYPE ANY,
Single field of a CT_VALUE_LIST entry
<lfs_single_value> TYPE ANY,
Generic field symbol
<lfs_attribute> TYPE ANY,
<lfs_attribute2> TYPE ANY.
*
************************************************************************
**
MAIN PROCESSING
************************************************************************
Get the user selections on the selector(custom fields only).
lt_matkey_tab_tmp = it_matkey_tab.
lt_user_selections[] = it_selection[].
DELETE lt_user_selections WHERE iobjnm_type <> 'U'.
*
DESCRIBE TABLE lt_user_selections LINES lv_lines.
*
***MOD-1921195.
LOOP AT CT_VALUE_LIST ASSIGNING <lfs_value_list>.
lv_tabix = sy-tabix.
ASSIGN COMPONENT lc_mktgr OF STRUCTURE <lfs_value_list>
TO <lfs_attribute>.
check <lfs_attribute> ne space.
Get the material id
READ TABLE lt_user_selections ASSIGNING <lfs_user_selections>
WITH KEY iobjnm = <lfs_attribute>.
IF SY-SUBRC NE 0.
DELETE CT_VALUE_LIST index lv_tabix.
ENDIF.
ENDLOOP.
***MOD-1921195.
*
LOOP AT lt_user_selections TRANSPORTING NO FIELDS
WHERE iobjnm = 'VARID' OR iobjnm = 'VARCT'
OR iobjnm = 'VARTX'.
*
lv_flag_var = 'X'.
EXIT.
ENDLOOP.
*
Form dynamic where condition
CLEAR lv_flag_sel.
LOOP AT lt_user_selections ASSIGNING <lfs_user_selections>.
lv_tabix = sy-tabix.
*
Clear variables
CLEAR : lv_col_name,
lv_col_value_low,
lv_col_value_high,
lv_col_option.
*
lv_col_name = <lfs_user_selections>-iobjnm. " Col Name
lv_col_option = <lfs_user_selections>-option. " Option
lv_col_sign = <lfs_user_selections>-sign. " Sign
*
*
**MOD-1921195.
IF lv_col_name eq 'BRFAM'.
*
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lv_col_value_low
IMPORTING
OUTPUT = lv_col_value_low.
*
ENDIF.
**MOD-1921195.
*
CONCATENATE lc_quote
<lfs_user_selections>-low
lc_quote
INTO lv_col_value_low. " Low value
*
CONCATENATE lc_quote
<lfs_user_selections>-high
lc_quote
INTO lv_col_value_high. " High value
*
CONDENSE : lv_col_name,
lv_col_value_low,
lv_col_value_high,
lv_col_option.
*
Form the WHERE condition to be used to
query the table ZD_APO_PRODVAR1
IF lv_col_name <> 'MATKL'.
Inclusion
IF lv_col_sign = 'I'.
IF lv_col_option = lc_bt." Option is BT, ie, multiple values
**MOD-1921195.
IF lv_col_name = 'BRFAM'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lv_col_value_low
IMPORTING
OUTPUT = lv_col_value_low.
ENDIF.
*
IF lv_col_name = 'ITPCK'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lv_col_value_low
IMPORTING
OUTPUT = lv_col_value_low.
*
ENDIF.
**MOD-1921195.
CONCATENATE lv_where_condn lv_par
lv_col_name
lc_between
lv_col_value_low
lc_and
lv_col_value_high
INTO lv_where_condn SEPARATED BY space.
*
ELSEIF lv_col_option = lc_eq. " Option is EQ, ie, single
"value
lv_flag_sel = 'X'.
**MOD-1921195.
IF lv_col_name = 'BRFAM'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lv_col_value_low
IMPORTING
OUTPUT = lv_col_value_low.
*
SEARCH lv_col_value_low for '&'.
IF sy-subrc EQ 0.
**MOD-1921195.
lv_col_value_low = '%L&%'.
lv_col_value_low = '%L&%'.
CONCATENATE lc_quote
lv_col_value_low
lc_quote
INTO lv_col_value_low.
**MOD-1921195.
CONCATENATE lv_where_condn lv_par
lv_col_name
'LIKE'
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ELSE.
**MOD-1921195.
CONCATENATE lv_where_condn lv_par
lv_col_name
lc_equal
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ENDIF.
ELSEIF lv_col_name = 'ITPCK'.
*
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lv_col_value_low
IMPORTING
OUTPUT = lv_col_value_low.
*
CONCATENATE lv_where_condn lv_par
lv_col_name
lc_equal
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
*
ELSE.
**MOD-1921195.
CONCATENATE lv_where_condn lv_par
lv_col_name
lc_equal
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ENDIF.
*
*
*
*
ELSEIF lv_col_option = lc_cp.
lv_flag_sel = 'X'.
**MOD-1921195.
IF lv_col_name = 'BRFAM'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lv_col_value_low
IMPORTING
OUTPUT = lv_col_value_low.
*
CALL FUNCTION 'CONVERSION_EXIT_ZSPCH_INPUT'
EXPORTING
INPUT = lv_col_value_low
IMPORTING
OUTPUT = lv_col_value_low
SEARCH lv_col_value_low for '&'.
IF sy-subrc EQ 0.
**MOD-1921195.
lv_col_value_low = '%L&%'.
lv_col_value_low = '%L&%'.
CONCATENATE lc_quote
lv_col_value_low
lc_quote
INTO lv_col_value_low.
**MOD-1921195.
CONCATENATE lv_where_condn lv_par
lv_col_name
'LIKE'
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ELSE.
**MOD-1921195.
REPLACE ALL OCCURRENCES OF '*' IN lv_col_value_low WITH
*'%'.
CONCATENATE lv_where_condn lv_par
lv_col_name
'LIKE'
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ENDIF.
ENDIF.
ENDIF.
**MOD-1921195.
Exclusion
ELSE.
ELSEIF lv_col_option = lc_bt." Option is BT, ie,
" multiple values
*
IF lv_col_option = lc_bt." Option is BT, ie, multiple
**values
**MOD-1921195.
IF lv_col_name = 'BRFAM'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lv_col_value_low
IMPORTING
OUTPUT = lv_col_value_low.
**MOD-1921195.
SEARCH lv_col_value_low for '&'.
IF sy-subrc EQ 0.
**MOD-1921195.
lv_col_value_low = '%L&%'.
lv_col_value_low = '%L&%'.
CONCATENATE lc_quote
lv_col_value_low
lc_quote
INTO lv_col_value_low.
**MOD-1921195.
*
CONCATENATE lv_where_condn lv_par
lv_col_name
'LIKE'
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ELSE.
**MOD-1921195.
CONCATENATE lv_where_condn lv_par
lv_col_name 'NOT'
lc_between
lv_col_value_low
lc_and
lv_col_value_high
INTO lv_where_condn SEPARATED BY space.
ENDIF.
ELSE.
CONCATENATE lv_where_condn lv_par
lv_col_name 'NOT'
lc_between
lv_col_value_low
lc_and
lv_col_value_high
INTO lv_where_condn SEPARATED BY space.
ENDIF.
ELSEIF lv_col_option = lc_eq. " Option is EQ, ie, single value
lv_flag_sel = 'X'.
**MOD-1921195.
IF lv_col_name = 'BRFAM'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lv_col_value_low
IMPORTING
OUTPUT = lv_col_value_low.
*
**MOD-1921195.
SEARCH lv_col_value_low for '&'.
IF sy-subrc EQ 0.
**MOD-1921195.
lv_col_value_low = '%L&%'.
lv_col_value_low = '%L&%'.
CONCATENATE lc_quote
lv_col_value_low
lc_quote
INTO lv_col_value_low.
**MOD-1921195.
CONCATENATE lv_where_condn lv_par
lv_col_name
'LIKE'
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ELSE.
**MOD-1921195.
*
CONCATENATE lv_where_condn lv_par
lv_col_name
lc_noteq
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ENDIF.
ELSE.
CONCATENATE lv_where_condn lv_par
lv_col_name
lc_noteq
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ENDIF.
ELSEIF lv_col_option = lc_cp.
lv_flag_sel = 'X'.
REPLACE ALL OCCURENCES OF '*' IN lv_col_value_low WITH '%'.
REPLACE ALL OCCURRENCES OF '*' IN lv_col_value_low WITH '%'.
CONCATENATE lv_where_condn lv_par
lv_col_name
'NOT LIKE'
lv_col_value_low
INTO lv_where_condn SEPARATED BY space.
ENDIF.
**MOD-1921195.
ELSE.
ls_matkl-sign = <lfs_user_selections>-sign.
ls_matkl-option = lv_col_option.
ls_matkl-low = <lfs_user_selections>-low.
ls_matkl-high = <lfs_user_selections>-high.
APPEND ls_matkl TO lr_matkl.
CONTINUE.
ENDIF.
**MOD-1921195.
*
More attributes left to be checked ?
IF sy-tabix < lv_lines.
lv_tabix = lv_tabix + 1.
READ TABLE lt_user_selections ASSIGNING <lfs_user_selections_n>
INDEX lv_tabix.
lv_col_name_new = <lfs_user_selections_n>-iobjnm.
IF lv_col_name <> lv_col_name_new.
CONCATENATE lv_where_condn lc_rpar
lc_and
INTO lv_where_condn SEPARATED BY space.
lv_par = lc_lpar.
ELSE.
IF lv_col_sign = 'I'.
CONCATENATE lv_where_condn
lc_or
INTO lv_where_condn SEPARATED BY space.
ELSE.
CONCATENATE lv_where_condn
lc_and
INTO lv_where_condn SEPARATED BY space.
ENDIF.
CLEAR lv_par.
ENDIF.
ENDIF.
*
ENDLOOP.
IF lv_flag_sel IS NOT INITIAL.
CONCATENATE lv_where_condn lc_rpar INTO lv_where_condn
SEPARATED BY space.
ENDIF.
*
TRY.
Get data of the table ZD_APO_PRODVAR1.
Retrieve the product values and the F4 values.
IF lv_where_condn IS NOT INITIAL.
Refine the select with materials available for selection
ls_matnr-sign = 'I'.
ls_matnr-option = 'EQ'.
loop at it_matkey_tab assigning <lfs_matkey>.
find lc_dot in <lfs_matkey>-matnr.
**MOD-1921195.
if sy-subrc = 0.
SPLIT <lfs_matkey>-matnr AT lc_dot INTO lv_dummymat lv_xtn.
ls_matnr-low = lv_dummymat.
else.
ls_matnr-low = <lfs_matkey>-matnr.
endif.
**MOD-1921195.
append ls_matnr to lr_matnr.
endloop.
clear: lv_dummymat, lv_xtn.
sort lr_matnr.
delete adjacent duplicates from lr_matnr
comparing all fields.
concatenate lv_where_condn lc_and 'PARPR IN LR_MATNR' into
lv_where_condn separated by space.
*
**MOD-1921195.
CONDENSE lv_where_condn.
TRY.
SELECT *
FROM zd_apo_prodvar1
INTO TABLE lt_data
WHERE (lv_where_condn).
***MOD-1921195.
*
TRY.
SELECT
TAB1~PRVAR
TAB1~PARPR
TAB1~VARID
TAB1~VARCT
TAB1~VARTX
TAB1~DMOAP
TAB2~PRDID
TAB2~BRFAM
TAB2~MATKL
TAB2~BRDIF
TAB2~MEIND
TAB2~MKLEN
TAB2~PCKTY
TAB2~ITPCK
TAB2~PMEIN
TAB2~MKTHK
TAB2~FLIND
TAB2~EDTID
TAB2~BNDTY
TAB2~ITBND
TAB2~ITCSE
TAB2~TPCOL
TAB2~SPFLV
TAB2~PRSHP
TAB2~MKTGR
TAB2~SUBMK
TAB2~BOMHD
TAB2~BRDSC
TAB2~MKSTR
TAB2~EDDSC
TAB2~EDCAT
TAB2~CCIND
TAB2~CGSTY
TAB2~FLTTY
TAB2~CPIND
TAB2~MBIND
TAB2~USPRP
TAB2~EDDET
TAB2~BRGEW
TAB2~NTGEW
TAB2~GEWEI
TAB2~VOLUM
TAB2~VOLEH
TAB2~MAKTX
TAB2~RPLVL
FROM ZDM0705 AS TAB1
INNER JOIN ZDMPCG1 AS TAB2
ON TAB1PARPR = TAB2PRDCD
INTO CORRESPONDING FIELDS OF TABLE lt_data
WHERE (lv_where_condn).
*
CATCH cx_sy_dynamic_osql_error.
MESSAGE s802(dh).
*
catch CX_SY_OPEN_SQL_DB.
If there is an error in the where condn, raise a message.
MESSAGE s801(dh).
ENDTRY.
**
***MOD-1921195.
*
***MOD-1921195.
IF not lr_matkl[] is INITIAL.
***MOD-1921195.
IF lr_matkl IS NOT INITIAL.
DELETE lt_matkey_tab_tmp WHERE NOT matkl IN lr_matkl.
LOOP AT lt_data ASSIGNING <lfs_data> .
CLEAR lv_flag.
LOOP AT lt_matkey_tab_tmp TRANSPORTING NO FIELDS
WHERE matnr = <lfs_data>-parpr OR
matnr = <lfs_data>-prvar.
lv_flag = 'X'.
ENDLOOP.
IF lv_flag IS INITIAL.
CLEAR <lfs_data>-parpr.
ENDIF.
ENDLOOP.
DELETE lt_data WHERE parpr IS INITIAL.
ENDIF.
ELSE.
SELECT matid locid matnr locno
INTO TABLE lt_matloc
FROM /sapapo/v_matloc
FOR ALL ENTRIES IN it_matloc
WHERE matid = it_matloc-matid AND
locid = it_matloc-locid.
IF sy-subrc = 0.
SORT lt_matloc BY matnr.
DELETE ADJACENT DUPLICATES FROM lt_matloc
COMPARING matnr.
SELECT *
FROM zd_apo_prodvar1
INTO TABLE lt_data
FOR ALL ENTRIES IN lt_matloc
WHERE parpr = lt_matloc-matnr OR
prvar = lt_matloc-matnr.
IF sy-subrc <> 0.
LOOP AT lt_matloc ASSIGNING <lfs_matloc>.
CLEAR ls_data.
FIND lc_dot IN <lfs_matloc>-matnr.
IF sy-subrc = 0.
ls_data-prvar = <lfs_matloc>-matnr.
SPLIT <lfs_matloc>-matnr AT lc_dot
INTO lv_dummymat lv_xtn.
ls_data-parpr = lv_dummymat.
ELSE.
ls_data-parpr = <lfs_matloc>-matnr.
ENDIF.
APPEND ls_data TO lt_data.
ENDLOOP.
ELSE.
IF lr_matkl IS NOT INITIAL.
DELETE lt_matkey_tab_tmp WHERE NOT matkl IN lr_matkl.
LOOP AT lt_data ASSIGNING <lfs_data> .
CLEAR lv_flag.
LOOP AT lt_matkey_tab_tmp TRANSPORTING NO FIELDS
WHERE matnr = <lfs_data>-parpr OR
matnr = <lfs_data>-prvar.
lv_flag = 'X'.
ENDLOOP.
IF lv_flag IS INITIAL.
CLEAR <lfs_data>-parpr.
ENDIF.
ENDLOOP.
DELETE lt_data WHERE parpr IS INITIAL.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*
catch CX_SY_OPEN_SQL_DB.
If there is an error in the where condn, raise a message.
MESSAGE s801(dh).
*
CATCH cx_sy_dynamic_osql_error.
If there is an error in the where condn, raise a message.
MESSAGE s802(dh).
ENDTRY.
*
Sort the data.
SORT lt_data BY prvar parpr.
*
Get table details for ZD_APO_PRODVAR1.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = lc_tabname " Table name(ZD_APO_PRODVAR1)
langu = sy-langu " Language
IMPORTING
ddobjtype = ls_table_type " Type of the table
TABLES
dfies_tab = lt_table_structure " Metadata of the table
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
*
IF ( sy-subrc <> 0 ) OR ( ls_table_type = 'INTTAB' ).
EXIT. " Exit from method
ENDIF.
*
Create values list reference
CREATE DATA lv_value_list_ref LIKE LINE OF ct_value_list.
ASSIGN lv_value_list_ref->* TO <lfs_value_list>.
*
Clear the existing entries
DELETE ct_value_list FROM 1.
*
LOOP AT ct_value_list ASSIGNING <lfs_value_list>.
lv_tabix = sy-tabix.
ASSIGN COMPONENT lc_matnr OF STRUCTURE <lfs_value_list>
TO <lfs_attribute>.
*
Get the material id
READ TABLE it_matkey_tab ASSIGNING <lfs_matkey>
WITH KEY matnr = <lfs_attribute>.
*
IF sy-subrc = 0.
lv_matid = <lfs_matkey>-matid.
ENDIF.
FIND lc_dot IN <lfs_attribute>.
*
If product is a core
IF sy-subrc <> 0.
If selection is based on variant based attributes cores
should not be displayed.
IF lv_flag_var IS NOT INITIAL.
DELETE ct_value_list INDEX lv_tabix.
CONTINUE.
ENDIF.
READ TABLE lt_data ASSIGNING <lfs_data>
WITH KEY parpr = <lfs_attribute>.
IF sy-subrc = 0.
IF <lfs_matkey>-matkl NOT IN lr_matkl.
DELETE ct_value_list INDEX lv_tabix.
CONTINUE.
ENDIF.
Loop through the field names of ZD_APO_PRODVAR1
LOOP AT lt_table_structure ASSIGNING <lfs_field>.
ASSIGN COMPONENT <lfs_field>-fieldname
OF STRUCTURE <lfs_data> TO <lfs_attribute>.
*
ASSIGN COMPONENT <lfs_field>-fieldname
OF STRUCTURE <lfs_value_list> TO <lfs_single_value>.
*
<lfs_single_value> = <lfs_attribute>.
ENDLOOP.
*
ASSIGN COMPONENT lc_matkl OF STRUCTURE <lfs_value_list>
TO <lfs_attribute2>.
*
<lfs_attribute2> = <lfs_matkey>-matkl.
*
Clear the variant specific attributes
ASSIGN COMPONENT lc_prvar
OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
CLEAR <lfs_attribute>.
ASSIGN COMPONENT lc_varid
OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
CLEAR <lfs_attribute>.
ASSIGN COMPONENT lc_varct
OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
CLEAR <lfs_attribute>.
ASSIGN COMPONENT lc_vartx
OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
CLEAR <lfs_attribute>.
ASSIGN COMPONENT lc_dmoap
OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
CLEAR <lfs_attribute>.
*
Get the location id
ASSIGN COMPONENT lc_locno OF STRUCTURE <lfs_value_list>
TO <lfs_attribute>.
READ TABLE it_loc ASSIGNING <lfs_loc>
WITH KEY locno = <lfs_attribute>.
IF sy-subrc = 0.
lv_locid = <lfs_loc>-locid.
ENDIF.
*
READ TABLE it_matloc ASSIGNING <lfs_matloc_int>
WITH KEY matid = lv_matid
locid = lv_locid.
IF sy-subrc = 0.
ASSIGN COMPONENT lc_plansnp
OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
*
<lfs_attribute> = <lfs_matloc_int>-planner_snp.
ENDIF.
ELSE.
DELETE ct_value_list INDEX lv_tabix.
CONTINUE.
ENDIF.
If the product is a variant
ELSE.
SPLIT <lfs_attribute> AT lc_dot INTO lv_dummymat lv_xtn.
READ TABLE lt_data ASSIGNING <lfs_data>
WITH KEY parpr = lv_dummymat
prvar = <lfs_attribute>.
IF sy-subrc = 0.
IF <lfs_matkey>-matkl NOT IN lr_matkl.
DELETE ct_value_list INDEX lv_tabix.
CONTINUE.
ENDIF.
Loop through the field names of ZD_APO_PRODVAR1
LOOP AT lt_table_structure ASSIGNING <lfs_field>.
ASSIGN COMPONENT <lfs_field>-fieldname
OF STRUCTURE <lfs_data> TO <lfs_attribute>.
*
ASSIGN COMPONENT <lfs_field>-fieldname
OF STRUCTURE <lfs_value_list> TO <lfs_single_value>.
*
<lfs_single_value> = <lfs_attribute>.
ENDLOOP.
*
ASSIGN COMPONENT lc_matkl OF STRUCTURE <lfs_value_list>
TO <lfs_attribute2>.
*
<lfs_attribute2> = <lfs_matkey>-matkl.
*
Get the location id
ASSIGN COMPONENT lc_locno OF STRUCTURE <lfs_value_list>
TO <lfs_attribute>.
READ TABLE it_loc ASSIGNING <lfs_loc>
WITH KEY locno = <lfs_attribute>.
IF sy-subrc = 0.
lv_locid = <lfs_loc>-locid.
ENDIF.
*
READ TABLE it_matloc ASSIGNING <lfs_matloc_int>
WITH KEY matid = lv_matid
locid = lv_locid.
IF sy-subrc = 0.
ASSIGN COMPONENT lc_plansnp
OF STRUCTURE <lfs_value_list> TO <lfs_attribute>.
*
<lfs_attribute> = <lfs_matloc_int>-planner_snp.
ENDIF.
ELSE.
DELETE ct_value_list INDEX lv_tabix.
CONTINUE.
ENDIF.
ENDIF.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
3 | |
2 | |
2 | |
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.