Duplicate materials
Hi
My requirement is
System have to check whether there is duplication material number on sales document (warning message).
Solution provided like this
Enhancement will be developed:
Use user exit MV45AFZZ on 'Save document prepare routine'. Ignore if there is scenario free goods material (check on item category level) and supersession
In include MV45AFZZ i can see Form save_document_prepare_routine'
endform which is empty..
can i write the code directly here??or anyting to do??
What code should write here??
Please and Thanks for your help in advance.
If you just need to report that there is duplicate, you can do something like this.
data: xxvbap type table of vbap.
data: x_lines type i,
xx_lines type i.
xxvbap[] = xvbap[].
sort xxvbap ascending by matnr.
delete adjacent duplicates from xxvbap comparing matnr.
describe xvbap lines x_lines.
describe xxvbap lines xx_lines.
if x_lines <> xx_lines.
message w001(00) with 'There is a dupicate material'.
endif.
Regards,
Rich Heilman
Similar Messages
-
Delete materials not assigned to any plant.
Dear Readers,
I am trying to find out a means by which I can identify and delete materials that are not assigned to any of the plants. During the data loads in Production, there were duplicate materials created and only one of the 5 duplicates is assigned to a plant. Is there a means of doing that with standard SAP programs or do we need to write a custom ABAP program for that.
There could be more than 10,000 materials like that.
Thank you for reading and answers are appreciated.if you know already the numbers of those unwanted materials, then you can archive them with SARA object MM_MATNR.
(it is not mandatory to set a deletion flag first)
if you dont know the materials that do not have plant views, then do se16 for table MARA and check the field PSTAT
The characters in the field indicate which view exist.
call MM50 and press F4 in field maintenance status to get info about what character represents which view. -
Material Cost estimate modification
Hi Experts
I want to modified this report and add cost estimate value from MBEW (field is STPRS) for each material to this report. I have used the table MBEW but unable to locate where to start.
Can anyone have a look and comment on this report
REPORT command_extract .
*CLASS cl_gui_control DEFINITION LOAD.
*CLASS cl_gui_frontend_services DEFINITION LOAD.
Tables
TABLES:
kna1,
knb1,
knvv,
mara,
mast, "JPC20061107
marc,
makt,
sscrfields.
CONSTANTS: BEGIN OF gc_status,
acc TYPE zcrstat1 VALUE ' ACC',
hol TYPE zcrstat1 VALUE ' HOL',
sto TYPE zcrstat1 VALUE ' STO',
ok TYPE zcrstat1 VALUE ' OK',
hold TYPE zcrstat1 VALUE 'HOLD',
END OF gc_status.
CONSTANTS: BEGIN OF gc_reason,
000 TYPE zreason VALUE '000',
001 TYPE zreason VALUE '001',
002 TYPE zreason VALUE '002',
003 TYPE zreason VALUE '003',
004 TYPE zreason VALUE '004',
005 TYPE zreason VALUE '005',
006 TYPE zreason VALUE '006',
007 TYPE zreason VALUE '007',
008 TYPE zreason VALUE '008',
010 TYPE zreason VALUE '010',
011 TYPE zreason VALUE '011',
021 TYPE zreason VALUE '021',
022 TYPE zreason VALUE '022',
023 TYPE zreason VALUE '023',
024 TYPE zreason VALUE '024',
025 TYPE zreason VALUE '025',
026 TYPE zreason VALUE '026',
999 TYPE zreason VALUE '999',
END OF gc_reason.
TYPES: BEGIN OF ty_kna1_fields,
kunnr TYPE kna1-kunnr,
sperr TYPE kna1-sperr,
aufsd TYPE kna1-aufsd,
lifsd TYPE kna1-lifsd,
faksd TYPE kna1-faksd,
loevm TYPE kna1-loevm,
END OF ty_kna1_fields.
TYPES: BEGIN OF ty_knb1_fields,
kunnr TYPE knb1-kunnr,
bukrs TYPE knb1-bukrs,
sperr TYPE knb1-sperr,
loevm TYPE knb1-loevm,
END OF ty_knb1_fields.
TYPES: BEGIN OF ty_knvv_fields,
kunnr TYPE knvv-kunnr,
vkorg TYPE knvv-vkorg,
vtweg TYPE knvv-vtweg,
spart TYPE knvv-spart,
aufsd TYPE knvv-aufsd,
lifsd TYPE knvv-lifsd,
faksd TYPE knvv-faksd,
END OF ty_knvv_fields.
TYPES: BEGIN OF ty_knkk_fields,
kunnr TYPE knkk-kunnr,
kkber TYPE knkk-kkber,
ctlpc TYPE knkk-ctlpc,
crblb TYPE knkk-crblb,
knkli TYPE knkk-knkli,
klimk TYPE knkk-klimk,
skfor TYPE knkk-skfor,
ssobl TYPE knkk-ssobl,
END OF ty_knkk_fields.
TYPES: BEGIN OF ty_cust_stat_output,
kunnr(10) TYPE c, "Customer #
stat(4) TYPE c, "Customer status
END OF ty_cust_stat_output.
TYPES:
BEGIN OF ty_customers,
kunnr(10) TYPE c, " Customer #
div1(1) TYPE c, " Pipe delimiter
name1(32) TYPE c, " Customer name
div2(1) TYPE c, " Pipe delimiter
altkn(8) TYPE c, " Old Customer #
div3(1) TYPE c, " Pipe delimiter
stras(30) TYPE c, " Street
div4(1) TYPE c, " Pipe delimiter
ort01(20) TYPE c, " City
div5(1) TYPE c, " Pipe delimiter
regio(3) TYPE c, " State
div6(1) TYPE c, " Pipe delimiter
pstlz(4) TYPE c, " Postcode
div7(1) TYPE c, " Pipe delimiter
telf1(14) TYPE c, " Phone 1
div8(1) TYPE c, " Pipe delimiter
telf2(14) TYPE c, " Phone 2
div9(1) TYPE c, " Pipe delimiter
erdat(10) TYPE c, " date
div10(1) TYPE c, " Pipe delimiter
splant(2) TYPE c, " plant
div11(1) TYPE c, " Pipe delimiter
END OF ty_customers,
it_ty_customers TYPE ty_customers OCCURS 0,
BEGIN OF ty_custstat,
kunnr(11) TYPE c, " Customer #
company(2) TYPE c, " #
status(3) TYPE c, " acc,cod,hol,
END OF ty_custstat,
it_ty_custstat TYPE ty_custstat OCCURS 0.
TYPES:
BEGIN OF ty_materialm,
matnr(12) TYPE c, " Material #
maktx2(40) TYPE c, " Command sales desc.
maktx(16) TYPE c, " Basic description
extwg(6) TYPE c, " External Material Group
flag1(1) TYPE c, "
flag2(1) TYPE c, "
flag3(1) TYPE c, "
flag4(1) TYPE c, "
END OF ty_materialm,
it_ty_materialm TYPE ty_materialm OCCURS 0,
BEGIN OF ty_materialp,
matnr(12) TYPE c, " Material #
werks(4) TYPE c, " plant
batch(1) TYPE c, " download to batch
END OF ty_materialp,
it_ty_materialp TYPE ty_materialp OCCURS 0.
TYPES:
BEGIN OF ty_bom,
matnr(12) TYPE c, " Material #
werks(4) TYPE c, " Plant
posnr(3) TYPE c, " position
idnrk(12) TYPE c, " BOM material #
menge(10) TYPE c, " Quantity
meins(3) TYPE c, " Unit of Measure
END OF ty_bom,
it_ty_bom TYPE ty_bom OCCURS 0,
*Start of block of changes for JPC20061107
BEGIN OF ty_bom_sapfmt,
matnr TYPE MAST-MATNR, " Material #
werks TYPE MAST-WERKS, " Plant
posnr TYPE STPO-POSNR, " position
idnrk TYPE STPO-IDNRK, " BOM material #
menge TYPE STPO-MENGE, " Quantity
meins TYPE STPO-MEINS, " Unit of Measure
potx1 TYPE STPO-POTX1, " Text description for BOM
END OF ty_bom_sapfmt.
BEGIN OF ty_bomlist,
matnr LIKE mast-matnr, " Material #
stlnr LIKE mast-stlnr, " BOM #
posnr LIKE stpo-posnr, " BOM item#
idnrk LIKE stpo-idnrk, " BOM material #
menge LIKE stpo-menge, " BOM material qty
meins LIKE stpo-meins, " BOM material uom
END OF ty_bomlist,
it_ty_bomlist TYPE ty_bomlist OCCURS 0.
*Ending block of changes for JPC20061107
Selection screen definition
SELECTION-SCREEN: BEGIN OF BLOCK gen WITH FRAME TITLE text-001.
PARAMETERS:
p_dir like rlgrap-filename obligatory, " extract directory
p_ccust TYPE c DEFAULT ' ' AS CHECKBOX, " Check box customers
p_cmatm TYPE c DEFAULT ' ' AS CHECKBOX, " Check box Materials
p_cbom TYPE c DEFAULT ' ' AS CHECKBOX, " Check box BOMs
p_ccst TYPE c DEFAULT ' ' AS CHECKBOX. " Check box credit stat
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-006.
PARAMETERS:
p_gui RADIOBUTTON GROUP rg1 USER-COMMAND u01,
p_svr RADIOBUTTON GROUP rg1 DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK a.
SELECTION-SCREEN: END OF BLOCK gen.
SELECTION-SCREEN: BEGIN OF BLOCK cust WITH FRAME TITLE text-002.
PARAMETERS:
p_dcust LIKE filepath-pathintern DEFAULT 'Z_COMMAND_CUST_EXTRACT',
p_fcust LIKE rlgrap-filename,
p_dcomp LIKE knb1-bukrs,
p_dsale LIKE knvv-vkorg,
p_dwerk(3) TYPE c.
SELECTION-SCREEN: END OF BLOCK cust.
SELECTION-SCREEN: BEGIN OF BLOCK matnr WITH FRAME TITLE text-003.
PARAMETERS:
p_dmatm LIKE filepath-pathintern
DEFAULT 'Z_COMMAND_MATERIAL_EXTRACT',
p_fmatm LIKE rlgrap-filename,
p_fmatp LIKE rlgrap-filename,
p_dwerks LIKE marc-werks,
p_dspras LIKE makt-spras,
p_dbatch(1) TYPE c,
p_dflag1(1) TYPE c,
p_dflag2(1) TYPE c,
p_dflag3(1) TYPE c,
p_dflag4(1) TYPE c.
SELECT-OPTIONS:
s_dextwg FOR mara-extwg.
SELECTION-SCREEN: END OF BLOCK matnr.
SELECTION-SCREEN: BEGIN OF BLOCK bom WITH FRAME TITLE text-004.
PARAMETERS:
p_dbom LIKE filepath-pathintern DEFAULT 'Z_COMMAND_BOM_EXTRACT',
p_fbom LIKE rlgrap-filename.
p_bwerks LIKE mast-werks. "Made a select-optoin JPC20061107
SELECT-OPTIONS:
s_bmatnr FOR MARA-MATNR, "JPC20061107
s_bwerks FOR MAST-WERKS no-extension no intervals, "JPC20061107
s_bextwg FOR mara-extwg.
SELECTION-SCREEN: END OF BLOCK bom.
SELECTION-SCREEN: BEGIN OF BLOCK ccst WITH FRAME TITLE text-005.
PARAMETERS:
p_dccst LIKE filepath-pathintern
DEFAULT 'Z_COMMAND_CUST_STAT_EXTRACT',
p_fccst LIKE rlgrap-filename,
p_fccst2 LIKE rlgrap-filename,
p_fccstl LIKE rlgrap-filename.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-007.
PARAMETERS: p_csall RADIOBUTTON GROUP gp2.
PARAMETERS: p_csdlt RADIOBUTTON GROUP gp2 DEFAULT 'X'.
PARAMETERS: p_append RADIOBUTTON GROUP GP3 DEFAULT 'X', "Append files output to server for cust credit data ?
p_owrite RADIOBUTTON GROUP GP3.
SELECTION-SCREEN END OF BLOCK b.
SELECT-OPTIONS:
s_kunnr FOR kna1-kunnr.
SELECTION-SCREEN: END OF BLOCK ccst.
DATA: clsdir TYPE REF TO cl_gui_frontend_services.
DATA: strfolder TYPE string.
DATA: folderln TYPE i.
DATA: gva_error(1) TYPE c VALUE ' '.
Initial procedure on START ***************
INITIALIZATION.
p_fcust = 'CUST.prn'.
p_fmatm = 'MATM.prn'.
p_fmatp = 'MATP.prn'.
p_fbom = 'BOM.prn'.
p_fccst = 'CCSTAT.prn'.
p_fccst2 = 'CCSTATC.prn'.
p_fccstl = 'CCSTATL.prn'.
s_dextwg-option = 'BT'.
s_dextwg-low = '1'.
s_dextwg-high = '8'.
APPEND s_dextwg.
s_bextwg-option = 'BT'.
s_bextwg-low = '1'.
s_bextwg-high = '1'.
APPEND s_bextwg.
AT SELECTION-SCREEN.
IF p_ccust EQ 'X' AND ( p_fcust IS INITIAL OR p_dcust IS INITIAL ).
MESSAGE s000(zppu)
WITH 'You must specify the file details for the customer data'.
gva_error = 'X'.
ENDIF.
IF p_cmatm EQ 'X' AND ( p_fmatm IS INITIAL OR
p_fmatp IS INITIAL OR
p_dmatm IS INITIAL ).
MESSAGE s001(zppu)
WITH 'You must specify the file details for the material data'.
gva_error = 'X'.
ENDIF.
IF p_cbom EQ 'X' AND ( p_fbom IS INITIAL OR p_dbom IS INITIAL ).
MESSAGE s002(zppu)
WITH 'You must specify the file details for the BOM data'.
gva_error = 'X'.
ENDIF.
IF p_cbom EQ 'X'.
IF s_bwerks-low is initial.
MESSAGE s002(zppu)
WITH 'You must specify a plant to run BOM extract for'.
gva_error = 'X'.
ENDIF.
IF LINES( s_bwerks ) > 1.
MESSAGE s002(zppu)
WITH 'You can only specify 1 plant for BOM extract'.
gva_error = 'X'.
ENDIF.
ENDIF.
IF p_ccst EQ 'X' AND ( p_fccst IS INITIAL OR
p_fccst2 IS INITIAL OR
p_fccstl IS INITIAL OR
p_dccst IS INITIAL ).
MESSAGE s002(zppu)
WITH 'You must specify the file details for the customer'
'status data'.
gva_error = 'X'.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
PERFORM user_command.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fcust.
PERFORM get_gui_filename USING p_dcust p_fcust.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fmatm.
PERFORM get_gui_filename USING p_dmatm p_fmatm.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fmatp.
PERFORM get_gui_filename USING p_dmatm p_fmatp.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fbom.
PERFORM get_gui_filename USING p_dbom p_fbom.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fccst.
PERFORM get_gui_filename USING p_dccst p_fccst.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fccst2.
PERFORM get_gui_filename USING p_dccst p_fccst2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fccstl.
PERFORM get_gui_filename USING p_dccst p_fccstl.
END-OF-SELECTION.
Data selection execution.
DATA: lwa_kna1 TYPE kna1,
lwa_knb1 TYPE knb1,
lwa_knvv TYPE knvv.
DATA: lwa_marc TYPE marc,
lwa_mara TYPE marav,
lwa_makt TYPE makt.
DATA: lit_marav TYPE marav OCCURS 0.
DATA: lit_customers TYPE it_ty_customers,
lwa_customers TYPE ty_customers.
DATA: lit_custstat TYPE it_ty_custstat,
lwa_custstat TYPE ty_custstat.
DATA: lit_materialm TYPE it_ty_materialm,
lwa_materialm TYPE ty_materialm.
DATA: lit_materialp TYPE it_ty_materialp,
lwa_materialp TYPE ty_materialp.
*(del)DATA: lwa_bomlist TYPE ty_bomlist, "JPC20061107
*(del) lit_bomlist TYPE it_ty_bomlist. "JPC20061107
DATA: lwa_bom TYPE ty_bom_sapfmt,
lit_bom TYPE it_ty_bom WITH HEADER LINE. "JPC20061107
lit_bom TYPE it_ty_bom. "JPC20061107
DATA: output_file TYPE string.
DATA: lock_file TYPE string.
DATA: lva_mssage TYPE string.
DATA: lva_matnr(18) TYPE n.
DATA: lva_date TYPE datum.
DATA: txtper(3) TYPE c.
DATA: custper TYPE i.
DATA: custcount TYPE i.
DATA: itemnum TYPE i.
CHECK gva_error <> 'X'.
IF p_ccust EQ 'X'. " Do the customer file extract
PERFORM extract_customer_details.
ENDIF.
IF p_cmatm EQ 'X'. " Do the Material file extract
PERFORM extract_material_details.
ENDIF.
IF p_cbom EQ 'X'. " Do the BOM file extract
PERFORM extract_bom_details.
ENDIF.
IF p_ccst EQ 'X'. " Do the customer credit status file extract
PERFORM extract_credit_status_details.
ENDIF.
*& Form extract_customer_details
text
--> p1 text
<-- p2 text
FORM extract_customer_details.
SELECT * FROM knb1
INTO lwa_knb1
WHERE bukrs = p_dcomp.
MOVE-CORRESPONDING lwa_knb1 TO lwa_customers.
MOVE-CORRESPONDING lwa_knb1 TO lwa_custstat.
MOVE '#' TO lwa_custstat-company.
MOVE p_dwerk TO lwa_customers-splant.
WG1K903075: Start Delete---*
move: '|' to lwa_customers-div1,
'|' to lwa_customers-div2,
'|' to lwa_customers-div3,
'|' to lwa_customers-div4,
'|' to lwa_customers-div5,
'|' to lwa_customers-div6,
'|' to lwa_customers-div7,
'|' to lwa_customers-div8,
'|' to lwa_customers-div9,
'|' to lwa_customers-div10,
'|' to lwa_customers-div11.
WG1K903075: End Delete-----*
WG1K903075: Start Insert---*
MOVE: ' ' TO lwa_customers-div1,
' ' TO lwa_customers-div2,
' ' TO lwa_customers-div3,
' ' TO lwa_customers-div4,
' ' TO lwa_customers-div5,
' ' TO lwa_customers-div6,
' ' TO lwa_customers-div7,
' ' TO lwa_customers-div8,
' ' TO lwa_customers-div9,
' ' TO lwa_customers-div10,
' ' TO lwa_customers-div11.
WG1K903075: End Insert-----*
APPEND lwa_customers TO lit_customers.
APPEND lwa_custstat TO lit_custstat.
ENDSELECT.
DESCRIBE TABLE lit_customers LINES custcount.
LOOP AT lit_customers INTO lwa_customers.
txtper = 100 * sy-tabix / custcount.
custper = txtper.
SELECT SINGLE * FROM kna1
INTO lwa_kna1
WHERE kunnr = lwa_customers-kunnr.
MOVE-CORRESPONDING lwa_kna1 TO lwa_customers.
lva_date = lwa_customers-erdat.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = lva_date
IMPORTING
date_external = lwa_customers-erdat
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
REPLACE ALL OCCURRENCES OF '.'
IN lwa_customers-erdat WITH '/'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = lwa_customers-kunnr
IMPORTING
output = lwa_customers-kunnr.
WRITE: lwa_customers-kunnr RIGHT-JUSTIFIED TO lwa_customers-kunnr.
MODIFY lit_customers FROM lwa_customers.
Percentage indicator display
lva_mssage = 'Extracting customers'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = custper
text = lva_mssage.
ENDLOOP.
IF p_gui IS INITIAL.
PERFORM get_file_path USING p_dcust p_fcust output_file.
OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
LOOP AT lit_customers INTO lwa_customers.
TRANSFER lwa_customers TO output_file.
ENDLOOP.
CLOSE DATASET output_file.
ELSE.
MESSAGE s002(zppu)
WITH 'Dataset' output_file 'cannot be opened on the server'.
ENDIF.
ELSE.
MOVE p_fcust TO output_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = output_file
filetype = 'ASC'
TABLES
data_tab = lit_customers
EXCEPTIONS
OTHERS = 11.
ENDIF.
output_file = custcount.
CONCATENATE
output_file
' Customers extracted'
INTO
lva_mssage.
message lva_mssage type 'I'.
ENDFORM. " extract_customer_details
*& Form extract_material_details
text
--> p1 text
<-- p2 text
FORM extract_material_details.
select maramatnr maramaktx
maramatkl marcwerks
SELECT *
FROM marav AS mara
INNER JOIN marc AS marc
ON marc~matnr EQ mara~matnr
INTO CORRESPONDING FIELDS OF lwa_mara
WHERE marc~werks = p_dwerks
AND mara~spras = 'EN'
AND mara~extwg IN s_dextwg.
MOVE-CORRESPONDING lwa_mara TO lwa_materialm.
WRITE: lwa_mara-matnr TO lwa_materialm-matnr.
MOVE: p_dflag1 TO lwa_materialm-flag1,
p_dflag2 TO lwa_materialm-flag2,
p_dflag3 TO lwa_materialm-flag3,
p_dflag4 TO lwa_materialm-flag4.
APPEND lwa_materialm TO lit_materialm.
ENDSELECT.
DESCRIBE TABLE lit_materialm LINES custcount.
LOOP AT lit_materialm INTO lwa_materialm.
txtper = 100 * sy-tabix / custcount.
custper = txtper.
CLEAR lwa_materialp.
CLEAR lwa_mara.
MOVE: lwa_materialm-matnr TO lwa_materialp-matnr,
p_dwerks TO lwa_materialp-werks,
p_dbatch TO lwa_materialp-batch.
APPEND lwa_materialp TO lit_materialp.
MOVE: lwa_materialm-matnr TO lva_matnr.
MOVE: lva_matnr TO lwa_mara-matnr.
SELECT SINGLE maktx FROM makt
INTO lwa_materialm-maktx2
WHERE matnr = lwa_mara-matnr
AND spras = p_dspras.
IF lwa_materialm-maktx2 IS INITIAL.
lwa_materialm-maktx2 = lwa_materialm-maktx.
ENDIF.
MODIFY lit_materialm FROM lwa_materialm.
Percentage indicator display
lva_mssage = 'Extracting materials'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = custper
text = lva_mssage.
ENDLOOP.
IF p_gui IS INITIAL.
PERFORM get_file_path USING p_dmatm p_fmatm output_file.
OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
LOOP AT lit_materialm INTO lwa_materialm.
TRANSFER lwa_materialm TO output_file.
ENDLOOP.
CLOSE DATASET output_file.
ELSE.
MESSAGE s002(zppu)
WITH 'Dataset' output_file 'cannot be opened on the server'.
ENDIF.
ELSE.
MOVE p_fmatm TO output_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = output_file
filetype = 'ASC'
write_field_separator = ' '
TABLES
data_tab = lit_materialm
EXCEPTIONS
OTHERS = 11.
ENDIF.
IF p_gui IS INITIAL.
PERFORM get_file_path USING p_dmatm p_fmatp output_file.
OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
LOOP AT lit_materialp INTO lwa_materialp.
TRANSFER lwa_materialp TO output_file.
ENDLOOP.
CLOSE DATASET output_file.
ELSE.
MESSAGE s002(zppu)
WITH 'Dataset' output_file 'cannot be opened on the server'.
ENDIF.
ELSE.
MOVE p_fmatp TO output_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = output_file
filetype = 'ASC'
write_field_separator = ' '
TABLES
data_tab = lit_materialp
EXCEPTIONS
OTHERS = 11.
ENDIF.
REFRESH lit_materialm.
ENDFORM. " extract_material_details
*& Form extract_bom_details
text
--> p1 text
<-- p2 text
FORM extract_bom_details.
Lines below commented out and replaced with SELECT from ABAP Query run from
transaction ZBOM. Previously duplicate materials were selected. JPC20061107
REFRESH lit_materialm.
SELECT *
FROM marav AS mara
INNER JOIN marc AS marc
ON marcmatnr EQ maramatnr
INTO CORRESPONDING FIELDS OF lwa_mara
WHERE marc~werks = p_bwerks
AND mara~spras = 'EN'
AND mara~extwg IN s_bextwg.
APPEND lwa_mara TO lit_marav.
ENDSELECT.
DESCRIBE TABLE lit_marav LINES custcount.
LOOP AT lit_marav INTO lwa_mara.
Percentage indicator calculation
txtper = 100 * sy-tabix / custcount.
custper = txtper.
SELECT
mast~matnr
mast~stlnr
stpo~posnr
stpo~idnrk
stpo~menge
stpo~meins
FROM mast AS mast
LEFT OUTER JOIN stpo AS stpo
ON stpostlnr EQ maststlnr
INTO lwa_bomlist
WHERE mast~matnr = lwa_mara-matnr.
CLEAR lwa_bom.
MOVE-CORRESPONDING lwa_bomlist TO lwa_bom.
WRITE: lwa_bomlist-matnr TO lwa_bom-matnr.
IF lwa_bomlist-idnrk IS INITIAL.
WRITE: 'BACKBIN' TO lwa_bom-idnrk.
ELSE.
WRITE: lwa_bomlist-idnrk TO lwa_bom-idnrk.
ENDIF.
MOVE: lwa_bomlist-posnr TO itemnum.
WRITE: itemnum TO lwa_bom-posnr RIGHT-JUSTIFIED.
write: lwa_bomlist-menge
to lwa_bom-menge
decimals 2.
MOVE: p_bwerks TO lwa_bom-werks.
APPEND lwa_bom TO lit_bom.
ENDSELECT.
Percentage indicator display
lva_mssage = 'Extracting material B.O.Ms'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = custper
text = lva_mssage.
ENDLOOP.
select MASTMATNR MASTWERKS STPOPOSNR STPOIDNRK STPOMENGE STPOMEINS "JPC20061220
select MAST~MATNR MAST~WERKS STPO~POSNR STPO~IDNRK STPO~MENGE STPO~MEINS STPO~POTX1 "JPC20061220
into lwa_bom
from ( MAST
inner join STKO
on STKO~STLAL = MAST~STLAL
and STKO~STLNR = MAST~STLNR
and STKO~WRKAN = MAST~WERKS
inner join MARA as MARA_H
on MARA_H~MATNR = MAST~MATNR
left outer join STAS
on STAS~STLAL = STKO~STLAL
and STAS~STLNR = STKO~STLNR
and STAS~STLTY = STKO~STLTY
inner join STPO
on STPO~STLKN = STAS~STLKN
and STPO~STLNR = STAS~STLNR
and STPO~STLTY = STAS~STLTY
inner join MARA JPC20061220
left outer join MARA "JPC20061220
on MARA~MATNR = STPO~IDNRK )
where MARA_H~MATNR in s_bmatnr
and MAST~WERKS in s_bwerks
and MARA_H~EXTWG in s_bextwg.
clear lit_bom.
WRITE lwa_bom-matnr TO lit_bom-matnr.
MOVE lwa_bom-werks TO lit_bom-werks.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = lwa_bom-posnr
IMPORTING
output = lit_bom-posnr.
SHIFT lit_bom-posnr right deleting trailing space.
IF lwa_bom-idnrk IS INITIAL.
WRITE 'BACKBIN' TO lit_bom-idnrk. JPC20061220
WRITE lwa_bom-potx1 TO lit_bom-idnrk. "JPC20061220
ELSE.
WRITE lwa_bom-idnrk TO lit_bom-idnrk.
ENDIF.
MOVE: lwa_bom-menge TO lit_bom-menge,
lwa_bom-meins TO lit_bom-meins.
APPEND lit_bom.
ENDSELECT.
SORT lit_bom ascending.
Ending for lines inserted for change 20061107
IF p_gui IS INITIAL. "write to server
PERFORM get_file_path USING p_dbom p_fbom output_file.
OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
custcount = lines( lit_bom ).
LOOP AT lit_bom.
txtper = 100 * sy-tabix / custcount.
custper = txtper.
lva_mssage = 'Extracting material B.O.Ms'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING percentage = custper
text = lva_mssage.
TRANSFER lit_bom TO output_file.
ENDLOOP.
CLOSE DATASET output_file.
ELSE.
MESSAGE s002(zppu)
WITH 'Dataset' output_file 'cannot be opened on the server'.
ENDIF.
ELSE.
MOVE p_fbom TO output_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = output_file
filetype = 'ASC'
write_field_separator = ' '
TABLES
data_tab = lit_bom
EXCEPTIONS
OTHERS = 11.
ENDIF.
ENDFORM. " extract_bom_details
*& Form get_file_path
text
-->P_LOGICAL_PATH_NAME text
-->P_FILENAME text
-->P_FILENAME_WITH_PATH text
FORM get_file_path USING p_logical_path_name p_filename
p_filename_with_path.
DATA: l_opsys TYPE sy-opsys,
l_blank_filename TYPE c,
l_filename TYPE string.
IF p_gui IS INITIAL.
MOVE 'WN32' TO l_opsys.
ELSE.
MOVE 'WN' TO l_opsys.
ENDIF.
IF p_filename IS INITIAL.
MOVE 'XXX' TO l_filename.
MOVE 'X' TO l_blank_filename.
ELSE.
MOVE p_filename TO l_filename.
ENDIF.
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
logical_path = p_logical_path_name
operating_system = l_opsys
file_name = l_filename
IMPORTING
file_name_with_path = p_filename_with_path
EXCEPTIONS
path_not_found = 1
missing_parameter = 2
operating_system_not_found = 3
file_system_not_found = 4
OTHERS = 5.
IF NOT l_blank_filename IS INITIAL.
REPLACE ALL OCCURRENCES OF 'XXX' IN p_filename_with_path WITH space.
ENDIF.
ENDFORM. "get_file_path
*& Form value_request_p_fcust
text
--> p1 text
<-- p2 text
FORM get_gui_filename USING p_path p_filename.
DATA: l_fdir TYPE string.
CHECK NOT p_gui IS INITIAL.
PERFORM get_file_path USING p_path space
l_fdir.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_path = l_fdir
mask = ',.prn,.prn.'
title = 'Select Excel file for download'
IMPORTING
filename = p_filename
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
ENDFORM. " value_request_p_fcust
*& Form extract_credit_status_details
text
--> p1 text
<-- p2 text
FORM extract_credit_status_details .
DATA: lt_credit_stat TYPE STANDARD TABLE OF zint_credit_stat,
l_credit_stat TYPE zint_credit_stat,
l_current_stat1 TYPE zcrstat1,
l_current_stat2 TYPE zcrstat2,
l_current_reason TYPE zreason,
lt_output_stat TYPE STANDARD TABLE OF zint_credit_stat,
l_output_stat TYPE zint_credit_stat,
lt_output1 TYPE STANDARD TABLE OF ty_cust_stat_output,
lt_output2 TYPE STANDARD TABLE OF ty_cust_stat_output,
l_output TYPE ty_cust_stat_output.
SELECT a~mandt a~kunnr a~name1 b~curstat1 b~curstat2 b~curtimestamp
b~curreason b~prevstat1 b~prevstat2 b~prvtimestamp
b~prevreason
INTO TABLE lt_credit_stat
FROM kna1 AS a
LEFT OUTER JOIN zint_credit_stat AS b
ON a~kunnr = b~kunnr
WHERE a~kunnr IN s_kunnr.
DESCRIBE TABLE lt_credit_stat LINES custcount.
LOOP AT lt_credit_stat INTO l_credit_stat.
txtper = 100 * sy-tabix / custcount.
custper = txtper.
PERFORM determine_current_status USING l_credit_stat-kunnr
l_current_stat1
l_current_stat2
l_current_reason.
IF NOT p_csdlt IS INITIAL.
Only do delta download
IF l_current_stat1 NE l_credit_stat-curstat1 OR
l_current_stat2 NE l_credit_stat-curstat2.
PERFORM add_record_to_output TABLES lt_output_stat
USING l_current_stat1
l_current_stat2
l_current_reason
l_credit_stat.
ENDIF.
ELSE.
Download all records
PERFORM add_record_to_output TABLES lt_output_stat
USING l_current_stat1
l_current_stat2
l_current_reason
l_credit_stat.
ENDIF.
Percentage indicator display
lva_mssage = 'Extracting customer status'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = custper
text = lva_mssage.
ENDLOOP.
Create output table
LOOP AT lt_output_stat INTO l_output_stat.
CLEAR l_output.
WRITE l_output_stat-kunnr TO l_output-kunnr.
SHIFT l_output-kunnr RIGHT DELETING TRAILING space.
MOVE l_output_stat-curstat1 TO l_output-stat.
APPEND l_output TO lt_output1.
MOVE l_output_stat-curstat2 TO l_output-stat.
APPEND l_output TO lt_output2.
ENDLOOP.
SORT lt_output1.
SORT lt_output2.
IF p_gui IS INITIAL.
Lock File
PERFORM get_file_path USING p_dccst p_fccstl lock_file.
If the file already exists then abort processing
OPEN DATASET lock_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 8.
MESSAGE s002(zppu)
WITH 'Lock file' lock_file 'already exists on server,'
'processing aborted'.
LEAVE PROGRAM.
ENDIF.
OPEN DATASET lock_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
MESSAGE s002(zppu)
WITH 'Lock file' lock_file 'cannot be opened on the server,'
'processing aborted'.
LEAVE PROGRAM.
ENDIF.
File 1
PERFORM get_file_path USING p_dccst p_fccst output_file.
If user requests cust status data to be appended use different OPEN
IF p_append is initial.
OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
ELSE.
OPEN DATASET output_file FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
ENDIF.
IF sy-subrc EQ 0.
LOOP AT lt_output1 INTO l_output.
TRANSFER l_output TO output_file.
ENDLOOP.
CLOSE DATASET output_file.
ELSE.
MESSAGE s002(zppu)
WITH 'Dataset' output_file 'cannot be opened on the server'.
ENDIF.
File 2
PERFORM get_file_path USING p_dccst p_fccst2 output_file.
If user requests cust status data to be appended use different OPEN
IF p_append is initial.
OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
ELSE.
OPEN DATASET output_file FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
ENDIF.
IF sy-subrc EQ 0.
LOOP AT lt_output2 INTO l_output.
TRANSFER l_output TO output_file.
ENDLOOP.
CLOSE DATASET output_file.
ELSE.
MESSAGE s002(zppu)
WITH 'Dataset' output_file 'cannot be opened on the server'.
ENDIF.
DELETE DATASET lock_file.
ELSE.
MOVE p_fccst TO output_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = output_file
filetype = 'ASC'
TABLES
data_tab = lt_output1
EXCEPTIONS
OTHERS = 11.
MOVE p_fccst2 TO output_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = output_file
filetype = 'ASC'
TABLES
data_tab = lt_output2
EXCEPTIONS
OTHERS = 11.
ENDIF.
IF NOT p_svr IS INITIAL.
PERFORM update_status_table TABLES lt_output_stat.
ENDIF.
output_file = custcount.
CONCATENATE
output_file
' Customers extracted'
INTO
lva_mssage.
ENDFORM. " extract_credit_status_details
*& Form user_command
text
--> p1 text
<-- p2 text
FORM user_command .
LOOP AT SCREEN.
IF screen-name EQ 'P_DCUST' OR
screen-name EQ '%_P_DCUST_%_APP_%-TEXT' OR
screen-name EQ 'P_DMATM' OR
screen-name EQ '%_P_DMATM_%_APP_%-TEXT' OR
screen-name EQ 'P_DBOM' OR
screen-name EQ '%_P_DBOM_%_APP_%-TEXT' OR
screen-name EQ 'P_DCCST' OR
screen-name EQ '%_P_DCCST_%_APP_%-TEXT' OR
screen-name EQ 'P_FCCSTL' OR
screen-name EQ '%_P_FCCSTL_%_APP_%-TEXT'.
IF p_gui IS INITIAL.
screen-input = 1.
screen-output = 1.
screen-invisible = 0.
screen-active = 1.
ELSE.
screen-input = 0.
screen-output = 0.
screen-invisible = 1.
screen-active = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDFORM. " user_command
*& Form determine_current_status
text
-->P_L_CREDIT_STAT_KUNNR text
-->P_L_CURRENT_STAT1 text
-->P_L_CURRENT_STAT2 text
FORM determine_current_status USING p_kunnr p_stat1 p_stat2 p_reason.
STATICS: lt_kna1 TYPE STANDARD TABLE OF ty_kna1_fields,
lt_knb1 TYPE STANDARD TABLE OF ty_knb1_fields,
lt_knvv TYPE STANDARD TABLE OF ty_knvv_fields,
lt_knkk TYPE STANDARD TABLE OF ty_knkk_fields.
DATA: l_kna1 TYPE ty_kna1_fields,
l_knb1 TYPE ty_knb1_fields,
l_knvv TYPE ty_knvv_fields,
l_knkk TYPE ty_knkk_fields,
l_faedt TYPE rfpos-faedt,
l_days TYPE p,
l_used TYPE rf02l-klprz.
IF lt_kna1[] IS INITIAL.
PERFORM load_kna1 TABLES lt_kna1.
ENDIF.
IF lt_knb1[] IS INITIAL.
PERFORM load_knb1 TABLES lt_knb1.
ENDIF.
IF lt_knvv[] IS INITIAL.
PERFORM load_knvv TABLES lt_knvv.
ENDIF.
IF lt_knkk[] IS INITIAL.
PERFORM load_knkk TABLES lt_knkk.
ENDIF.
MOVE gc_status-acc TO p_stat1.
MOVE gc_status-ok TO p_stat2.
MOVE gc_reason-000 TO p_reason.
Customer Block/Unblock
READ TABLE lt_kna1 INTO l_kna1 WITH KEY kunnr = p_kunnr BINARY SEARCH.
IF sy-subrc EQ 0.
IF NOT l_kna1-sperr IS INITIAL.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-001 TO p_reason.
ENDIF.
IF l_kna1-aufsd EQ '01'.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-002 TO p_reason.
ENDIF.
IF l_kna1-lifsd EQ '01'.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-003 TO p_reason.
ENDIF.
IF l_kna1-faksd EQ '01'.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-004 TO p_reason.
ENDIF.
IF NOT l_kna1-loevm IS INITIAL.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-999 TO p_reason.
ENDIF.
ENDIF.
CHECK p_stat1 NE gc_status-sto.
LOOP AT lt_knb1 INTO l_knb1 WHERE kunnr EQ p_kunnr.
IF NOT l_kna1-sperr IS INITIAL.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-005 TO p_reason.
ENDIF.
IF NOT l_knb1-loevm IS INITIAL.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-999 TO p_reason.
ENDIF.
IF p_stat1 EQ gc_status-sto.
EXIT.
ENDIF.
ENDLOOP.
CHECK p_stat1 NE gc_status-sto.
LOOP AT lt_knvv INTO l_knvv WHERE kunnr EQ p_kunnr.
IF l_knvv-aufsd EQ '01'.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-006 TO p_reason.
ENDIF.
IF l_knvv-lifsd EQ '01'.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-007 TO p_reason.
ENDIF.
IF l_knvv-faksd EQ '01'.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-008 TO p_reason.
ENDIF.
IF p_stat1 EQ gc_status-sto.
EXIT.
ENDIF.
ENDLOOP.
CHECK p_stat1 NE gc_status-sto.
READ TABLE lt_knkk INTO l_knkk WITH KEY kunnr = p_kunnr
kkber = 'BP01'
BINARY SEARCH.
IF sy-subrc EQ 0.
Exceeded Trading Terms
IF l_knkk-ctlpc EQ 'Z03' OR
l_knkk-ctlpc EQ 'Z04' OR
l_knkk-ctlpc EQ 'Z05'.
CALL FUNCTION 'CUSTOMER_OLDEST_OPEN_ITEM'
EXPORTING
i_kkber = l_knkk-kkber
i_kunnr = l_knkk-kunnr
IMPORTING
e_faedt = l_faedt
EXCEPTIONS
invalid_call = 1
no_bukrs = 2
no_items = 3
OTHERS = 4.
IF sy-subrc EQ 0.
l_days = sy-datum - l_faedt.
ELSE.
l_days = 0.
ENDIF.
IF l_knkk-ctlpc EQ 'Z03' AND l_knkk-crblb IS INITIAL AND
l_days GT 45.
MOVE gc_status-hol TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-021 TO p_reason.
ENDIF.
IF l_knkk-ctlpc EQ 'Z04' AND l_knkk-crblb IS INITIAL AND
l_days GT 40.
MOVE gc_status-hol TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-022 TO p_reason.
ENDIF.
IF l_knkk-ctlpc EQ 'Z05' AND l_knkk-crblb IS INITIAL AND
l_days GT 30.
MOVE gc_status-hol TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-023 TO p_reason.
ENDIF.
IF l_knkk-ctlpc EQ 'Z03' AND NOT l_knkk-crblb IS INITIAL AND
l_days GT 45.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-024 TO p_reason.
ENDIF.
IF l_knkk-ctlpc EQ 'Z04' AND NOT l_knkk-crblb IS INITIAL AND
l_days GT 40.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-025 TO p_reason.
ENDIF.
IF l_knkk-ctlpc EQ 'Z05' AND NOT l_knkk-crblb IS INITIAL AND
l_days GT 30.
MOVE gc_status-sto TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-026 TO p_reason.
ENDIF.
CHECK p_stat1 NE gc_status-sto.
Exceeded Credit Limit Checks
PERFORM get_credit_exposure USING l_knkk-knkli l_knkk-kkber
l_knkk-ctlpc l_knkk-klimk
l_knkk-skfor l_knkk-ssobl
l_used.
IF l_used GE 95 AND l_knkk-crblb IS INITIAL.
MOVE gc_status-hol TO p_stat1.
MOVE gc_status-hold TO p_stat2.
MOVE gc_reason-010 TO p_reason.
ENDIF.
IF l_used GE 95 AND NOT l_knkk-crblb IS INITIAL.
MOVE gc_status-Yes thread closed
Prioz -
User Exit during Sales Order Creation - New Line Item needed
I have a situation during the process of sales order creation. If a Material in a line item has say 27 EA and the Base Unit is EA. But the Sales Unit is CSE. Then whenever the user enters 27 EA and presses enter he should get two line items.
The first line item needs to convert to maximum number of CSE posible and the rest will be the second line item with the remaining EA. The order isn't important but that is what is needed. Question is how do I approach this problem and code my user exit accordingly and where do I code it.
I was looking at SAPMV45A and saw the program MV45AIZZ which is meant as a user exit for any PAI event handling. If anybody has encountered this kind of requirement can you please share your view on this.
I will definitely reward points for useful answers.
ClarkHello Mahendra
The requirement is as follows :
PART 1:
Sales Order Enter:
1. When a line item is entered on a sales order (VA01 or VA02), at enter, check the sales unit of measure (VBAP-VRKME).
Do not check line items where item category (VBAP-PSTYV) = TANN, TAPS or ZTAP. TANN are free goods that should not be considered for consolidation. TAPS & ZTAP are lower level materials as a result of product selection. They will be attached to a higher-level material with an item category of TAX, which is relevant for consolidation.
Do not check items where VRKME <> EA
2. If VRKME = EA, go to MARM for MATNR.
3. Go to record where alternate unit of measure (MEINH) = CSE, get the value from the numerator field (UMREZ).
4. Divide the order quantity (VBEP-WMENG) by UMREZ.
5. If the result is greater than 1.0, the customer has ordered more than one case and a new line item needs to be added to the sales order for the case quantity.
6. Add a new line to VBAP for the same material with the case quantity. If not a whole value, the remainder of eaches (bottles) should update the qty on the first item on VBAP.
Part 1 is relevant for order types ZCA, ZOR, ZSO, RE, ZSM
PART 2:
Batch Job to run prior to the Delivery Due List:
1. Read VBUK for Delivery Status (LFSTK) = A (delivery not processed). Get all of the document numbers (VBELN).
2. Go to VBEP for those document numbers to get the goods issue date for the order. There will be many records in VBEP for the same sales order. Look at all orders with a goods issue date (WADAT) of next day.
3. Go to VBAK for those document numbers to see if there are multiple sales orders for the same Sold To party (KUNNR).
4. For customers who have more than one order in VBAK, search all line items (for all orders). If there are no duplicate materials across sales orders, do nothing.
Do not check line items where item category (VBAP-PSTYV) = TANN, TAPS or ZTAP. TANN are free goods that should not be considered for consolidation. TAPS & ZTAP are lower level materials as a result of product selection. They will be attached to a higher-level material with an item category of TAX, which is relevant for consolidation.
Do not check line items where reason for rejection (VBAP-ABGRU) is not blank
5. If there are duplicate materials, go through the same logic as in part 1. If the quantity across the sales orders adds up to greater than one case, add the appropriate quantity to a new line item on the first sales order. If there is a remainder qty, update the line item on the first sales order with this qty. In this case, the quantities on the second sales order needs to be closed out with a reason for rejection code of 50, Line Item Consolidation. If there is no remainder, update the qty on this item directly.
Part 2 is relevant for order types ZOR, ZCA, ZSM
This batch job will have to be run manually for Day Pick orders. The end of this program should automatically kick off the delivery due list for Day Pick orders, shipping condition 02.
Business Justification:
The business requires that like order line items be consolidated to one line item prior to the order going to the warehouse for picking. This will aid in picking at the warehouse as well as result in the customer invoice not reflecting more than one line item for the same material. In the case where the customer has truly ordered more than a case, i.e;, 1 case, 2 bottles, the documents in SAP will still reflect 2 lines. -
Hi All,
Ii have built a generic extractor as Master data, it has fields like MATRNR, WERKS, DESC and PRCTR. Now I want to load it to another IOB. Should I create an info object with attributes such as WERKS, PRCTR and DESC for a master data object ZMATNR?
My concern is can I use the existing IOB like 0PLANT, 0PROFIT_CTR as attribute to my Z-object ZMATNR, C18, no text, with ZDESC as another text item. Though it is not a typical master data situation (Lots of duplicate materials accross plants are possible). I don't want to create a DSO to avoid activateion time load issues.
Am I right? Any second openions?
Thanks,
Alex (Arthur Samson)Thank for all.
I completed the design and it worked well. -
Design the New process set up for Materials in one physical stock serving p
Hi Experts,
The requirement is one physical plant as two different logical plants in the system. The main issue is how to administrate or how to find the set up which allows one Physical warehouse in Hamburg which we have supplying two Logical warehouses in the system without having thru really physically separate the warehouses into two different ones. Materials physically will be only for one warehouse.
Most of the things are pointing in the direction that order Backlogs will not be converted into new organization. We have backlogs for the material requirements for purchase orders, sales orders whatever we have in the current setup; then there will have all are new orders from the certain dates taking in the new organization set up. These backlogs are very long at least three to four years.
We would like to find some way to have the all the material requirements ending up in one basket instead of two baskets. That still be able to deliver at least in system point of view from two different baskets.
We need to do analysis on one physical stock serving plant into two different system plants that could be done either by material master data or as i understood that could be from PS side.
can any one please tell me how we can maintian this setup in the system.
Please provide your valuable inputs.
Brgds,
RK
Note : Duplicate post locked this thread
Edited by: Jeyakanthan A on Jun 3, 2011 2:29 PMRK,
Sorry, the creation of such an end-to-end solution is outside the scope of an online forum. Most consulting companies would send a multi-disciplinary team to perform this task, and would take several weeks to research your requirements, and come up with a prototype.
Sales order availability checking is described in SAP online help
http://help.sap.com/saphelp_erp60_sp/helpdata/en/93/744b51546011d1a7020000e829fd11/frameset.htm
I will say this. If your goal is to have two plants, with two company codes, and you wish to only procure or produce in one of the plants, then generally I would recommend using Special Procurement via Stock Transport Order (in standard SAP, Special Procurement 40). This based on a very small knowledge of your requirements. I have already cited the Sap online help for special procurement.
SAP online help for Warehouse management is at
http://help.sap.com/saphelp_erp60_sp/helpdata/en/c6/f8386f4afa11d182b90000e829fbfe/frameset.htm
As you begin to read the required topics, I am certain you will realize that this task is beyond the capability of an untrained person. I again suggest that you search for professional consulting services to assist you in this project. It will be money well spent.
I am now closing my responses to this thread. Good luck in your project!
Best Regards,
DB49 -
Restrict duplicate condition type in va01
Hello Experts.
I want to restrict user from entering duplicate condition types in tcode va01, how can I go about it?
Is there any user exit or BADI available, if yes please let me know how to go about it
Thanks in Advance...HI deven,
Check any one from the below :
Enhancement
V45S0001 Update sales document from configuration
V45S0003 MRP-relevance for incomplete configuration
V45S0004 Effectivity type in sales order
V45W0001 SD Service Management: Forward Contract Data to Item
V46H0001 SD Customer functions for resource-related billing
V60F0001 SD Billing plan (customer enhancement) diff. to billing plan
SDAPO001 Activating Sourcing Subitem Quantity Propagation
V45A0001 Determine alternative materials for product selection
SDTRM001 Reschedule schedule lines without a new ATP check
V45A0002 Predefine sold-to party in sales document
V45A0003 Collector for customer function modulpool MV45A
V45A0004 Copy packing proposal
V45P0001 SD customer function for cross-company code sales
V45L0001 SD component supplier processing (customer enhancements)
V45E0002 Data transfer in procurement elements (PRreq., assembly)
V45E0001 Update the purchase order from the sales order
Business Add-in
BADI_SD_SCH_GETWAGFZ Scheduling Agreement: Read WAGFZ from S073
Regards
Abhii -
Duplicate check through Referece field in MIRO
Hi All,
Can any one tell me, how i can make Reference field ( structure INVFO-XBLNR) check in MIRO transaction.
Requirement is that, system should not allow posting two MIRO documents with same Reference number, duplicate check should be done from Reference field.
is there any standard config abailable, should i look for exit.
Regards,
Sursh Patipati
Note : Subject is discussed widely, Please search forum before posting.
Edited by: Jeyakanthan A on Nov 17, 2011 10:36 PMHi,
If you have set duplicate invoice check in a particular Vendor Master record and there is an entry in the Reference field when you enter an invoice for this vendor, the system always checks if there is an invoice containing same data as which just entered.
The following check criteria can be used
- Co, Code.
- Vendor
- Currency
- Reference
- Invoice Date
- Amount
You must specify in customizing whether the Co. Code, reference and Invoice date are included in the check.
Path: IMG->Materials Management->Logistics Invoice Verification-> Incoming Invoice-> Set check for duplicate Invoices (T-Code: OMRDC)
If it finds an invoice that matches all these attributes (Message # M8 108) is issued as error or information.
Hope this serve your purpose!
Reetesh -
XSLT to remove duplicates while concatinating
My XML looks like folloing:
<?xml version="1.0" encoding="utf-8" standalone="no"?> <BATCHES> <item> <Material>1000000079</Material> <Description>330 Bulk</Description> <Tank>T123</Tank> <Batch>2013225287</Batch> <Quantity>510</Quantity> </item> <item> <Material>1000000079</Material> <Description>330 Bulk</Description> <Tank>T123</Tank> <Batch>2013225301</Batch> <Quantity>520</Quantity> </item> <item> <Material>1000000196</Material> <Description>340R Bulk</Description> <Tank>T700</Tank> <Batch>1000188378</Batch> <Quantity>510</Quantity> </item> <item> <Material>1000002754</Material> <Description>43 Bulk</Description> <Tank>T515</Tank> <Batch>2013180125</Batch> <Quantity>300</Quantity> </item> <item> <Material>1000002754</Material> <Description>43 Bulk</Description> <Tank>T515</Tank> <Batch>2013203124</Batch> <Quantity>200</Quantity> </item> <item> <Material>1000002754</Material> <Description>43 Bulk</Description> <Tank>T515</Tank> <Batch>2013214839</Batch> <Quantity>700</Quantity> </item> <item> <Material>1000002754</Material> <Description>43 Bulk</Description> <Tank>T517</Tank> <Batch>2013214342</Batch> <Quantity>890</Quantity> </item> </BATCHES>
My original XSLT look like this:
<?xml version="1.0" encoding="utf-8" standalone="no"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0"/> <xsl:template match="/"> <Rowsets> <Rowset> <xsl:variable name="materials" select=".//item[Tank!='RECV' and Tank!='PARK'] "/> <xsl:for-each select="$materials"> <xsl:if test="generate-id(.)= generate-id($materials[Material=current()/Material])"> <Row> <Material> <xsl:value-of select="Material"/> </Material> <Description> <xsl:value-of select="Description"/> </Description> <Value> <xsl:for-each select="$materials[Material=current()/Material]/Tank"> <xsl:if test="node()"> <xsl:value-of select="concat(.,'||')"/> </xsl:if> </xsl:for-each> </Value> </Row> </xsl:if> </xsl:for-each> </Rowset> </Rowsets> </xsl:template> </xsl:stylesheet>
The result of this XSLT looks like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <Rowsets> <Rowset> <Row> <Material>1000000079</Material> <Description>330 Bulk</Description> <Value>T123||T123||</Value> </Row> <Row> <Material>1000000196</Material> <Description>340R Bulk</Description> <Value>T700||</Value> </Row> <Row> <Material>1000002754</Material> <Description>43 Bulk</Description> <Value>T515||T517||</Value> </Row> </Rowset> </Rowsets>
I wanted to remove duplicate tanks while concatenating it in Value field. So I changed my XSLT to following:
<?xml version="1.0" encoding="utf-8" standalone="no"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0"/> <xsl:template match="/"> <Rowsets> <Rowset> <xsl:variable name="materials" select=".//item[Tank!='RECV' and Tank!='PARK' and Quantity > 500]"/> <xsl:for-each select="$materials"> <xsl:if test="generate-id(.)= generate-id($materials[Material=current()/Material])"> <Row> <Material> <xsl:value-of select="Material"/> </Material> <Description> <xsl:value-of select="Description"/> </Description> <Value> <xsl:for-each select="$materials[Material=current()/Material]/Tank[not(.=preceding::Tank)]"> <xsl:if test="node()"> <xsl:value-of select="concat(.,'||')"/> </xsl:if> </xsl:for-each> </Value> </Row> </xsl:if> </xsl:for-each> </Rowset> </Rowsets> </xsl:template> </xsl:stylesheet>
My result now looks like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <Rowsets> <Rowset> <Row> <Material>1000000079</Material> <Description>330 Bulk</Description> <Value>T123||</Value> </Row> <Row> <Material>1000000196</Material> <Description>340R Bulk</Description> <Value>T700||</Value> </Row> <Row> <Material>1000002754</Material> <Description>43 Bulk</Description> <Value>T517||</Value> </Row> </Rowset> </Rowsets>
It removed the duplicate tank T123 for material 1000000079 but for material 1000002754, it even removed T515which should appear in Value field as its quantity is greater than 500 for following:
<item> <Material>1000002754</Material> <Description>43 Bulk</Description> <Tank>T515</Tank> <Batch>2013214839</Batch> <Quantity>700</Quantity> </item>
what am I doing wrong here?And if columns are NULLable:
with sample_table as (
select '111' col1,'AAA' col2 from dual union all
select 'AAA','111' from dual union all
select '222','BBB' from dual union all
select '333','CCC' from dual union all
select '444',to_char(null) from dual union all
select to_char(null),'444' from dual union all
select to_char(null),to_char(null) from dual union all
select to_char(null),to_char(null) from dual
select least(col1,col2) col1,
case
when col1 is null then col2
when col2 is null then col1
else greatest(col1,col2)
end
from sample_table s
group by least(col1,col2),
case
when col1 is null then col2
when col2 is null then col1
else greatest(col1,col2)
end
order by least(s.col1,s.col2),
case
when s.col1 is null then s.col2
when s.col2 is null then s.col1
else greatest(s.col1,s.col2)
end
COL CAS
111 AAA
222 BBB
333 CCC
444
SQL> SY. -
Cross Repository Duplicate Check
Dear Gurus,
We have a huge data migration that happens in 34 countires, the MDM is centrally connected and each country have their own repositories ( Vendor, Customer, Materials ).
My question is, is it possible to do a duplicate check on datas ( customer, vendor, materials )across repositories.
Bes Regards,
SKHi Sathya,
Since they are standalone repositories , unfortunatley it is not possible to check duplicates across them.
You can identify duplicates only in central and then send back to countires repositories. But still not possible across Customer, Vendor and Materials.
I guess with MDM 7 , it will be possible.
Hope this helps,
+ An -
How do i check ensure that SAP checks for duplicate vendor invoice numbers?
Hi Experts -
How do I verify that SAP checks for duplicate vendor invoice numbers and blocks duplicate invoices from being paid?
Thanks!Hi
Pls chek the settigs by following the path
IMG>Materials Management>Logistics Invoice Verification>Incoming Invoice>Set Check for Duplicate Invoice.
Here you make the settings for creating a duplicate invoice check.
Moreever, in the vendor master, you need to tick the check box for duplicate invoice check.
I suggest you search the Forums before posting a query. There are lots of postings on this issue.
Thanks & regards
Sanil K Bhandari -
Duplicate Invoice Check -Vendor
Hi everyone,
I found out that I posted an invoice(FB60) for the same vendor with same, amount, reference,invoice date,same company code.one invoice was posted on 3rd march and other was posted on 25th march,I checked in the vendor master record indicator" chk double inv" is checked.Why system didn't give any error or warning message.Please guide.
Regards
ShaunHi,
Good Day,
Please follow the below steps ( taken from another post and its working fine for me)
The following fields must be identical for Duplicate invoice check
Company code (BUKRS)
Vendor number (LIFNR)
Currency (WAERS)
Reference number (XBLNR)
Amount in document currency (WRBTR)
Document date (BLDAT)
If the document is having any one of the above filed different then the
system does not consider it as a duplicate invoice.
and also It will check duplicate invoice check in vendor master data
and in posting key is there check box selected for sales related
The setting you making in OMRDC i.e Materials management->Logistics
Invoice Verification->Incoming Invoice ->Set Check for Duplicate
Invoices is only valid for MM and not FI invoices posted via FB60/FB65.
You should check the F1 help on field "Chk double inv." (LFB1-REPRF)
in the relevant vendor master record (transaction FK03).
Please also check, that message F5 117 has been set correctly in the
IMG using this path:
Financial Accounting -> Financial Accounting Global Settings ->
Document -> Default Values for Document Processing -> Change Message
Control for Document Control For Document Processing
Finally & mainly, go to the relevant posting key is defined as sales
related in transaction OB41. You have to flag this field if the
duplicate invoice check should work.
Best Regards,
KSK -
Vendor duplicate invoice check ???
Dear Expert.
Since in for FI documents will check double invoice when we post invoice with the same
- Company code
- Vendor
- Currency
- Document date
- Reference number
But our client would like to see or check double invoice if it is raised by different
VENDOR
For example, if we post invoice in FI with
- company code: 1000, vendor code: A, Currency USD, Document date: 01.04.2009 and invoice no. 1234
and we also post invoice in FI with
- company code: 1000, vendor code: B, Currency USD, Document date: 02.04.2009 and invoice no. 1234
So is there any Standard report or standard Configuration check available ?? Or How I can achive this ?Hi Uday,
Please check the steps again:
SPRO --> Materials Mangemnt ...> Purchasing ...> Partner Determination
A. Define Partner role
B.Define Permissible Partner Roles per Account Group( In this step, you can specify for each account group of the vendor which roles the vendor may assume.)
C.Partner Settings in Vendor Master Record
In this section, you define partner determination schemas and assign them to account groups.
D.Define Partner Schemas
In this step, you define partner determination schemas.
E. Assign Partner Schemas to Account Groups
F. You need to include the Partner Function PI in the Partner Schema assigned to your PO document type.
MM-Purchasing -partner Determination - partner settings in purchasing documents
Apart from the above setting if you have set duplicate invoice check in a particular Vendor Master record and there is an entry in the Reference field when you enter an invoice for this vendor, the system always checks if there is an invoice containing same data as which just entered.
The following check criteria can be used
- Co, Code.
- Vendor
- Currency
- Reference
- Invoice Date
- Amount
You must specify in customizing whether the Co. Code, reference and Invoice date are included in the check.
If it finds an invoice that matches all these attributes (Message # M8 108) is issued as error or information.
All these are SAP standard settings; and they should work. You can always look to enhance the check logic with the help of a BADI or FM Exit.
Hope this is useful.
Thanks,
Reetesh -
Validation for duplicate AP invoice
We would like to prevent duplicate AP invoices from being posted through FB60. We created an FI validation in OB28 in which the prerequisite = Tcode FB60, and the check is a user exit to check the values in vendor / company code / reference fields and if those 3 fields have the same values as in an existing document, to generate an error message preventing the duplicate document from being posted.
The above works well for creating new invoices. However, when we have to make changes to an existing invoice (created through FB60), the system also calls on that validation and generates the error message, even though the only fields we can change on the invoice is payment terms, payment method, payment method supplement and text.
Other than modifying the user exit, does anybody know of a better way to do this validation or to prevent duplicate manual invoice from being created?
thank you.This has already been answered before so extracted part of the reply
there are two duplicate checks in SAP:
1. the one for FI documents, this is relevant for all F... postings (but nor for MIRO!)
this can be turned off or on (in vendor master record) and 6 fields are checked:
Check Flag for Double Invoices or Credit Memos
Indicator which means that incoming invoices and credit memos are checked for double entries at the time of entry.
Use
Checking Logistics documents
Firstly, the system checks whether the invoice documents have already been entered in the Logistics invoice verification; the system checks invoices that are incorrect, or invoices that were entered for invoice verification in the background.
Checking FI documents
The system then checks whether there are FI or Accounting documents that were created with the original invoice verification or the Logistics verification, and where the relevant criteria are the same.
Checking Logistics documents
In checking for duplicate invoices, the system compares the following characteristics by default:
Vendor
Currency
Company code
Gross amount of the invoice
Reference document number
Invoice document date
If all of these characteristics are the same, the system issues a message that you can customize.
When you enter credit memos or subsequent adjustments, the system does not check for duplicate invoices.
Exception: Country-specific solution for Argentina, where invoices and credit memos are checked for duplicate documents.
No message is issued if you enter a document that has previously been reversed.
Dependencies
The system only checks for duplicate invoices in Materials Management if you enter the reference document number upon entering the invoice.
In Customizing for the Logistics invoice verification, you can specify that the following characteristics should not be checked:
Reference document number
Invoice document date
Company code
This means that you can increase the likelihood that the system will find a duplicate invoice, because you can reduce the number of characteristics checked.
Example
The following document has already been entered and posted:
Reference document number: 333
Invoice date: 04/28/00
Gross invoice amount: 100.00
Currency: EUR
Vendor: Spencer
Company code: Munich
You have made the following settings in Customizing:
The field "Reference document number" and "Company code" are deselected, which means that these characteristics will not be checked.
Now you enter the following document:
Reference document number: 334
Invoice date: 04/28/00
Gross invoice amount: 100.00
Currency: EUR
Vendor: Spencer
Company code: Berlin
Result
Because you entered a reference document when you entered the invoice, the system checks for duplicate invoices.
The reference document number and the company code are different from the invoice entered earlier, but these characteristics are not checked due to the settings you have made in Customizing.
All other characteristics are the same. As a result, the system issues a message that a duplicate entry has been made.
If the "Reference document number" had been selected in Customizing, the system would have checked the document and discovered that it was different from the invoice entered earlier, so it would not have issued a message.
Checking FI documents
Depending on the entry in the field "Reference", one of the following checks is carried out:
1. If a reference number was specified in the sequential invoice/credit memo, the system checks whether an invoice/credit memo has been posted where all the following attributes agree:
Company code
Vendor
Currency
Document date
Reference number
2. If no reference number was specified in the sequential invoice/credit memo, the system checks whether an invoice/credit memo has been posted where all the following attributes agree:
Company code
Vendor
Currency
Document date
Amount in document currency
2. the one for LIV.
this can be customized (as stated above) and is relevant for MIRO (and not for F... postings!).
Company, Reference and Invoice date
Set Check for Duplicate Invoices
In this step, you can configure for each company code if the system is to check for duplicate invoices when you enter invoices.
This check should prevent incoming invoices being accidentally entered and paid more than once.
You can choose whether to activate or deactivate the check criteria of company code, reference document number and invoice date for each company code. The more criteria that you activate, the lower the probability of the system finding a duplicate invoice. The Accounting documents are checked first, followed by documents from Logistics Invoice Verification (only incorrect invoices or those entered for verification in the background).
When checking duplicate invoices, the system compares the following
attributes in the standard system:
Vendor
Currency Company code
Gross invoice amount Reference document number
1. Invoice date If the system finds an invoice that matches all attributes, the system
displays a customizable message.
If you are entering credit memos, subsequent debits, or subsequent
credits, the system does not check for duplicate invoices.
The exception is the Argentina country version, where the system checks
for duplicate invoices and credit memos.
If a previously processed document is later cancelled and then entered
again, no message is displayed.
Requirements
The system only checks for duplicate invoices in Materials Management
if you specify a reference document number when entering the invoice.
In Customizing (IMG) for Invoice Verification, you can specify that the
system check the following attributes -
Cubes on Materials management Cube 0IC_C03
HI,
We need to create cubes on the Materials management Cube 0IC_C03 to take care of the huge inventory data we have . These will be a copy of 0IC_C03 and 0IC_C03 will be a staging layer.
Want to know how will the marker update will work on the new cubes?
Thanks.
NitinHi,
Dont enter duplicate trds pls close trd if u got solution
Cheers,
Satya
Maybe you are looking for
-
Any ideas about how I can be allowed to make purchases in itunes again? TIA
-
Safari font changed after installing Word?
I just purchased a new IMAC and please bare with me as I'm new to the apple line of computers. anyway, I installed microsoft word and now my fonts on safari are this weird cartoonish font. I cannot for the life of me figure out how to change it back
-
Misleading play count on movies
This is probably more an idea than a problem, but I post it here to see what others think of it. We and our children love to watch movies on two iPads and on AppleTV. We are all sharing the same Home Sharing account. Many of the movies are played aga
-
Help with component progressBar and Loader
The progress bar doesn't work if the .swf movie that's being loaded is being loaded into another movie. If the loader is on the main stage it works fine both in testing and on the internet. For example, I created a parent movie and a child movie with
-
Hi to the people on the forum, I have a Lenovo 3000 J110 series, my system is too slow having a core 2 duo processor, I try to find something on the bios to try to make more faster, I find cpu max id was disable, I enable it, but after of thease my s