Distribution of material cost wihich dosent come BOM
My client is producing bicycle. In this process first production process is degreasing.
In degreasing process small pipes (used for creation of bicycle frames) will be cleaned using few chemicals.
The pipes are different sizes. Different sized pipes will be used for different small, big bicycle production.
Now my problem is how can I distribute that cost of chemical for small, big pipes to find out production cost at that stage in sap.
(In company this cost will be distributed on the base of surface of pipe or frame )
thanku
j
Similar Messages
-
Material cost estimate using recursive BOM
Hello everybody.
I want create material cost estimate (CK11N) using a recipe with recursive BOM. When I execute the transaction CK11N the following message is display Costing of cycle 00001 does not converge
Do you know what is missing?
Thanks in advance.Dear,
Message no CK740?
Please do check the link below......
http://help.sap.com/erp2005_ehp_03/helpdata/EN/f8/a3e333bf3d11d189900000e8214595/content.htm
and OSS note : 858384
Regards,
R.Brahmankar -
Material costed, production order with no target cost
I've a case of production order and I don't where to find information to solve it.
I've a product A costed from March. Standard cost is correct.
I'm creating a production order now. The cost estimate is calculated during the delivery.
I've confirmed order by CO15. I've created a variance by deleting 2 items in bom of order. And confirm less than wanted on other component. But I don't think these variances are linked to my problem.
In CO02 and cost analysis : target cost of my product equals 0.
I've checked my prod cost variant and choices are : std price, L price from PIR, moving average price.
Thanks for your helps
ChristopheHow can I see that ? I've checked that material cost has taken the bom during the cost explosion. Components are also costed.
I've noticed that target cost appears after variance calculation for product. -
I am creating a report to show the expected material cost, the ebs forms BOM / Bills / Indented Bills, but the help \ record history don't show record history.
how to find the tables for this screen?Hi Ken, I created the PR by running MRP for the project. I then set the price of $900 in the PR that the system generated and saved it.
EDIT: I want to mention that the requisition MRP generated has an account assignment category Q and is linked to the WBS element of my activity. -
How to include Material Cost in the SD report
Hi,
I am working on Cube 0SD_C03 for the Sales and Distribution Report "Sales Contribution - Product Wise u2013 KPI" where I have to show the following information which are given below.
1. Total Sales Qty.
2. Total Sales Value
3. Total Material Cost
For third one I do not know how to include this in this SD report.
so please tell me about this if anybody has idea about this?Hi Francisco,
Note:
your xml should only have
<URL>http://dbxserver.dbxprts.com:7778/pls/apex/f?p=134:1:::NO::P1_ID_CONSTANCIA:1183</URL>
Show me your sample XML , i can help you.
What is your expected output ? PDF or HTML ?
here it is.
option1:
If the XML data includes an element that contains a hyperlink , then you can use that element to create dynamic hyperlinks at runtime.
a. insert hyperlink from word menu
b. In the Type the file or Web page name field of the Insert Hyperlink dialog box, enter the following syntax:
c. {ELEMENT_NAME_WHICH_HAS_URL_LINK}
where ELEMENT_NAME_WHICH_HAS_URL_LINK is the xml data element name
option2:
create a form field, you can add it
<fo:basic-link external-destination="http://www.google..com">
<fo:inline text-decoration="underline">google Link</fo:inline>
</fo:basic-link>
or
<fo:basic-link external-destination="{ELEMENT_NAME}">
<fo:inline text-decoration="underline">google Link</fo:inline>
</fo:basic-link>
or
<fo:basic-link>
<xsl:attribute name="external-destination"><xsl:value-of select="ELEMENT_URL"/>
</xsl:attribute>
<xsl:value-of select="LINK_NAME"/>
</fo:basic-link> -
Functinality to compare two material price with reference to BOM in CO
Hi All,
Is there is any functionality in Controlling which can compare the costing for two FERT materials.
or
is there is any functionality where we can compare two material price with reference to BOM in controlling
Please help me to compare the material price with reference to BOM
Regards
nanduHi,
You can use this report to compare two itemizations. The report compares the characteristics item number, item category, cost element, resource, material, cost center, plant/work center, cost center/activity type, operation number, BOM item, assembly indicator, and cost component.
You can access this report as follows:
Accounting ® Controlling ® Product Cost Controlling ® Product Cost Planning ® Material Costing ® Cost Estimate with Quantity Structure or Cost Estimate Without Quantity Structure ® Compare
or
Accounting ® Controlling ® Product Cost Controlling ® Product Cost Planning ® Information System ® Object Comparisons ® For Material ® Itemization Comparison.
For Detail Please reffer following link:
http://help.sap.com/saphelp_46c/helpdata/en/56/abd108f1a611d28a950000e8214595/content.htm
Thanks and Regards
Binoj M D -
Material Cost estimate realted issue and question
Hello,
we have a multi level BOM, I have makre and released for one sub level material in the BOM, there are few other sub- materils which need to be costed, can i do the cost estimate for the highest level of BOM or do i need to do first for each sub- component in the BOM, also for the one sum- companent wchi is realesed can that be changed.
please let me know.Hi
Both are in one way the same.
Material cost estimate can be calculated as
1. Material with quantity structure
2. Material without quantity structure
You can get more insight into it at the following link
http://help.sap.com/saphelp_47x200/helpdata/en/7e/cb938143a311d189ee0000e81ddfac/frameset.htm
Regards,
Suraj -
Hi Everyone,
Need to create a query to find raw material cost of each sales/based on AR/ invoice- quantity varies in each sales. Is there anyway around?
Thanks
Edited by: Anoop Jacob on Feb 20, 2009 2:09 PMHi Suda,
Have created a query as below, search function not seems working WHERE (T0.DocNum = 1249)-
instead given -
WHERE T0.[DocNum] = [%0]. -
Also this query dosent drill down to child BOM any sugetions will be great!!
SELECT DISTINCT T4.Code, T0.DocEntry, T4.OrigPrice, T6.BaseQty, T1.Quantity, T6.BaseQty * T1.Quantity * T4.OrigPrice AS 'Total'
FROM OINV AS T0 INNER JOIN
INV1 AS T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
OITM AS T2 ON T1.ItemCode = T2.ItemCode INNER JOIN
OITT AS T3 ON T2.ItemCode = T3.Code INNER JOIN
ITT1 AS T4 ON T3.Code = T4.Father INNER JOIN
OWOR AS T5 ON T3.Code = T5.ItemCode INNER JOIN
WOR1 AS T6 ON T5.DocEntry = T6.DocEntry AND T4.Code = T6.ItemCode INNER JOIN
OINM AS T7 ON T2.ItemCode = T7.ItemCode
WHERE (T0.DocNum = 1249)
GROUP BY T4.Code, T4.OrigPrice, T6.BaseQty, T1.Quantity, T6.BaseQty * T1.Quantity * T4.OrigPrice, T0.DocEntry
HAVING (NOT (T4.Code LIKE N'%%Labour%%')) AND (NOT (T4.Code LIKE N'%%Overhead%%'))
Regards,
Edited by: Anoop Jacob on Feb 23, 2009 1:23 PM -
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 -
How to get report for cost estimates material cost only
Hi Gurus,
We have requirement in sales order costing that we need to develope report which shows only Material cost for all BOM levels.
Normally at lower levels cost of Material and activity cost will be treated as Material cost for next level. Here I want to consider only material cost not activity cost at lower levels
Pls suggest the logic and tables for exploding BOM and fetching material cost only.
Thanks
SnehaSneha
If you tick the "Roll up" indicatorfor each cost component in Cost Comp Str OKTZ, then overheads do not get added to the material cost... This is my understanding about it.. Is it behaving some thing different in your case??
br, Ajay M -
Hi,
any one can help in this issue.
i am not getting the raw materila cost & manfacture conversion cost for for the bom of FG - SFG - SFG - SFG- RAW
FG - finished goods,
SFG - semi finished goods
RAW - raw material.
plz provide the solution.
raw material and manfacture conversion cost is calculated in PERFORM z_process_data. subroutine.
REPORT z_co_production_cost_nsk.
TABLES: afko, bkpf, t001w , caufv.
TYPE-POOLS: kkblo,
slis.
DATA: d_datefrom LIKE sy-datum,
d_dateto LIKE sy-datum,
d_repid LIKE sy-repid,
d_uname LIKE sy-uname,
d_returncode TYPE i,
d_tabix TYPE i,
d_kokrs LIKE tka01-kokrs,
d_waers LIKE tka01-waers,
wa_fieldcatalog TYPE slis_fieldcat_main,
wa_listevents TYPE slis_alv_event,
wa_listlayout TYPE slis_layout_alv,
wa_print_info TYPE slis_print_alv,
wa_listheader TYPE slis_listheader,
d_headerlines TYPE i.
DATA: BEGIN OF t_caufv OCCURS 0,
aufnr TYPE caufv-aufnr,
werks TYPE caufv-werks,
objnr TYPE covp-objnr,
gamng TYPE caufv-gamng,
plnbez TYPE caufv-plnbez,
rsnum TYPE caufv-rsnum,
END OF t_caufv.
*Added by Anand Bothra on 24/11/2003
DATA: t_ab_caufv LIKE t_caufv OCCURS 0 WITH HEADER LINE.
DATA: t_temp_caufv LIKE t_caufv OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF t_afpo OCCURS 0,
aufnr TYPE afpo-aufnr,
posnr TYPE afpo-posnr,
wemng TYPE afpo-wemng,
amein TYPE afpo-amein,
charg TYPE afpo-charg,
END OF t_afpo.
DATA: BEGIN OF t_afpo1 OCCURS 0,
aufnr TYPE afpo-aufnr,
refaufnr TYPE afpo-aufnr,
objnr TYPE caufv-objnr,
rsnum TYPE afko-rsnum,
wemng TYPE afpo-wemng,
werks TYPE afpo-dwerk,
charg TYPE afpo-charg,
END OF t_afpo1.
DATA: BEGIN OF t_makt OCCURS 0,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
END OF t_makt.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv,
t_listevents TYPE slis_t_event,
t_sortsequence TYPE slis_t_sortinfo_alv,
t_listheader TYPE slis_t_listheader.
DATA: BEGIN OF t_production_costs OCCURS 0,
objnr TYPE covp-objnr, " Object Number
kstar TYPE covp-kstar, " Cost Element
wkgbtr TYPE covp-wkgbtr, " Cost of Line Item in CO area curr
mbgbtr TYPE covp-mbgbtr, " Quantity of Line Item
matnr TYPE covp-matnr, " Material Number
kokrs TYPE covp-kokrs, " Controlling Area
belnr TYPE covp-belnr, " Cost Accounting Document
buzei TYPE covp-buzei, " Item Number in Document
END OF t_production_costs.
DATA: BEGIN OF t_production_costs1 OCCURS 0,
objnr TYPE covp-objnr, " Object Number
kstar TYPE covp-kstar, " Cost Element
wkgbtr TYPE covp-wkgbtr, " Cost of Line Item in CO area curr
mbgbtr TYPE covp-mbgbtr, " Quantity of Line Item
kokrs TYPE covp-kokrs, " Controlling Area
belnr TYPE covp-belnr, " Cost Accounting Document
buzei TYPE covp-buzei, " Item Number in Document
END OF t_production_costs1.
DATA t_production_costs2 LIKE t_production_costs1
OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF t_suborders OCCURS 0,
aufnr TYPE caufv-aufnr,
prevaufnr TYPE caufv-aufnr,
objnr TYPE covp-objnr,
rsnum TYPE caufv-rsnum,
END OF t_suborders.
DATA: BEGIN OF t_outputtab OCCURS 0,
plnbez LIKE afko-plnbez, " Material Number
objnr LIKE caufv-objnr, " Object Number
maktx LIKE makt-maktx, " Material Description
charg LIKE afpo-charg, " Batch Number
aufnr LIKE afko-aufnr, " Production Order Number
gamng LIKE caufv-gamng, " Total Order Quantity
wemng LIKE afpo-wemng, " Goods Receipt Quantity
amein LIKE afpo-amein, " Unit of Measure
yield TYPE p DECIMALS 2, " Percentage Yield
totalrmcost TYPE p DECIMALS 2, " Total Raw Material Cost
totalpmcost TYPE p DECIMALS 2, " Total Packing Mat. Cost
mfgconvcost TYPE p DECIMALS 2, " Manu. Conversion Cost
pkgconvcost TYPE p DECIMALS 2, " Packing Conv. Cost
rmperunit TYPE p DECIMALS 2, " Raw Cost per unit
pmperunit TYPE p DECIMALS 2, " Pack Mat cost per unit
ccperunit TYPE p DECIMALS 2, " Conv Cost per unit
totperunit TYPE p DECIMALS 2, " Total Cost per unit
waers LIKE tka01-waers, " Currency Key for CO Area
END OF t_outputtab.
*Added by Anand Bothra on 24/11/2003.
DATA: t_ab_outputtab LIKE t_outputtab OCCURS 0 WITH HEADER LINE,
t_temp_outputtab LIKE t_outputtab OCCURS 0 WITH HEADER LINE.
BEGIN OF INSERTION VIP110703
DATA:wa_prev_outputtab LIKE LINE OF t_outputtab,
wa_production_costs LIKE LINE OF t_production_costs.
DATA:prev_totmatqty TYPE p DECIMALS 2,
prev_tot_mfgconv_cst TYPE p DECIMALS 2,
grand_mat_qty TYPE p DECIMALS 2 ,
tmp_aufnr TYPE caufv-aufnr.
DATA: BEGIN OF t_suborders_propcost OCCURS 0,
aufnr TYPE caufv-aufnr,
prevaufnr TYPE caufv-aufnr,
objnr TYPE covp-objnr,
rsnum TYPE caufv-rsnum,
proprmcost TYPE p DECIMALS 2,
prop_mfg_convcost TYPE p DECIMALS 2,
END OF t_suborders_propcost.
DATA: wa_suborders LIKE LINE OF t_suborders.
END OF INSERTION VIP110703
BEGIN OF INSERTION VIP111003
DATA: prev_aufnr TYPE caufv-aufnr,
prev_matnr TYPE mara-matnr,
curr_matnr TYPE mara-matnr.
DATA: bln_suborder ,
ratio TYPE p DECIMALS 5.
BEGIN OF INSERTION VIP111003
*Added by Anand Bothra on 28/11/2003
DATA: d_flag TYPE c.
SELECTION-SCREEN BEGIN OF BLOCK zblock1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_plnbez FOR afko-plnbez,
s_aufnr FOR afko-aufnr,
"Added By Vivek on 29.11.2005
s_auart FOR caufv-auart obligatory.
PARAMETERS p_werks LIKE t001w-werks OBLIGATORY.
SELECTION-SCREEN END OF BLOCK zblock1.
SELECTION-SCREEN BEGIN OF BLOCK zblock2 WITH FRAME TITLE text-002.
SELECT-OPTIONS: s_monat FOR bkpf-monat NO-EXTENSION OBLIGATORY.
PARAMETERS p_gjahr LIKE bkpf-gjahr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK zblock2.
SELECTION-SCREEN BEGIN OF BLOCK zblock3 WITH FRAME TITLE text-022.
PARAMETERS: p_detsum RADIOBUTTON GROUP rad,
p_sum RADIOBUTTON GROUP rad.
SELECTION-SCREEN END OF BLOCK zblock3.
INITIALIZATION.
d_repid = sy-repid.
d_uname = sy-uname.
p_werks = 'G001'.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name EQ 'P_WERKS'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN ON s_monat.
IF s_monat-high IS INITIAL.
IF NOT ( s_monat-low BETWEEN 1 AND 12 ).
MESSAGE e398(00) WITH text-023 text-024 space space.
ENDIF.
ELSE.
IF ( ( s_monat-low LT 1 ) OR ( s_monat-high GT 12 ) ).
MESSAGE e398(00) WITH text-023 text-024 text-025 space.
ENDIF.
ENDIF.
START-OF-SELECTION.
PERFORM z_get_period_dates.
PERFORM z_select_prod_orders.
PERFORM z_select_prod_costs.
PERFORM z_select_addl_prod_costs.
PERFORM z_select_mat_desc.
END-OF-SELECTION.
IF d_returncode EQ 0.
PERFORM z_process_data.
*Added by Anand Bothra on 24/11/2004.
PERFORM z_select_to_print.
PERFORM z_prepare_fieldcat.
PERFORM z_get_alv_events.
PERFORM z_define_sortsequence.
PERFORM z_define_layout.
PERFORM z_display_list.
*Added by Anand Botra on 25/11/2003.
PERFORM z_export_to_excel.
PERFORM z_send_mail_and_download.
ELSE.
MESSAGE i017(p5).
ENDIF.
*& Form Z_GET_PERIOD_DATES
text
--> p1 text
<-- p2 text
FORM z_get_period_dates.
Determine the date range from the fiscal period range and
fiscal year entered on the selection screen
DATA: d_firstdate LIKE sy-datum,
d_lastdate LIKE sy-datum,
t_dates LIKE scscp_period_str OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET'
EXPORTING
i_gjahr = p_gjahr
i_periv = 'V3'
IMPORTING
e_first_day = d_firstdate
e_last_day = d_lastdate
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
CALL FUNCTION 'CSCP_PARA1_GET_PERIODS'
EXPORTING
i_datuv = d_firstdate
i_datub = d_lastdate
i_timeunit = 'M'
TABLES
et_dates = t_dates.
SORT t_dates BY sindex.
DELETE t_dates INDEX 1.
LOOP AT t_dates.
SUBTRACT: 1 FROM t_dates-sindex,
1 FROM t_dates-datub.
MODIFY t_dates TRANSPORTING sindex datub.
ENDLOOP.
CLEAR: d_datefrom,
t_dates.
READ TABLE t_dates WITH KEY sindex = s_monat-low.
d_datefrom = t_dates-datuv.
CLEAR d_dateto.
IF s_monat-high IS INITIAL.
d_dateto = t_dates-datub.
ELSE.
CLEAR t_dates.
READ TABLE t_dates WITH KEY sindex = s_monat-high.
d_dateto = t_dates-datub.
ENDIF.
ENDFORM. " Z_GET_PERIOD_DATES
*& Form Z_SELECT_PROD_ORDERS
text
--> p1 text
<-- p2 text
FORM z_select_prod_orders.
Select all production orders as per the selection criteria provided
DATA: d_dlv_code LIKE jstat-stat,
d_teco_code LIKE jstat-stat,
t_status LIKE jstat OCCURS 0 WITH HEADER LINE.
SELECT SINGLE name1 INTO t001w-name1 FROM t001w WHERE werks = p_werks.
if s_plnbez-low eq space and s_plnbez-high eq space.
endif.
SELECT aufnr werks objnr gamng rsnum plnbez
INTO CORRESPONDING FIELDS OF
TABLE t_caufv FROM caufv
WHERE aufnr IN s_aufnr
AND auart IN ('PP01', 'LL02') : BY VIVEK
AND auart in s_auart " Added By Vivek on 29.11.2005
AND werks = p_werks
AND plnbez IN s_plnbez
AND getri BETWEEN d_datefrom AND d_dateto
ORDER BY aufnr.
d_returncode = sy-subrc.
IF d_returncode NE 0.
STOP.
ENDIF.
Filter out only those production orders that have a status
DLV (Delivered) or TECO (Technically Confirmed).
CLEAR: d_dlv_code,
d_teco_code.
PERFORM z_get_status_code USING 'DLV' CHANGING d_dlv_code.
PERFORM z_get_status_code USING 'TECO' CHANGING d_teco_code.
LOOP AT t_caufv.
REFRESH t_status.
CALL FUNCTION 'STATUS_READ'
EXPORTING
CLIENT = SY-MANDT
objnr = t_caufv-objnr
only_active = 'X'
IMPORTING
OBTYP =
STSMA =
STONR =
TABLES
status = t_status
EXCEPTIONS
object_not_found = 1
OTHERS = 2
IF sy-subrc EQ 0.
CLEAR t_status.
READ TABLE t_status WITH KEY stat = d_dlv_code.
IF sy-subrc NE 0.
CLEAR t_status.
READ TABLE t_status WITH KEY stat = d_teco_code.
IF sy-subrc NE 0.
DELETE t_caufv.
ENDIF.
ENDIF.
ELSE.
DELETE t_caufv.
ENDIF.
ENDLOOP.
IF t_caufv[] IS INITIAL.
d_returncode = 4.
STOP.
ENDIF.
Added by Anand Bothra on 24/11/2003**********
t_ab_caufv[] = t_caufv[].
Added by Anand Bothra on 28/11/2003.
IF ( s_plnbez-low EQ space AND s_plnbez-high EQ space ).
IF ( s_aufnr-low EQ space AND s_aufnr-high EQ space ).
d_flag = 'N'.
ELSE.
d_flag = 'Y'.
ENDIF.
ELSE.
d_flag = 'Y'.
ENDIF.
IF d_flag = 'Y'.
Added by Anand Bothra on 21/11/2003.**********
*Get the batch number of the entered order
DATA: itab_afpo LIKE afpo OCCURS 100 WITH HEADER LINE.
DATA: BEGIN OF t_ab_charg OCCURS 0,
*Added by Anand on 27/11/2003
aufnr LIKE afpo-aufnr,
charg LIKE afpo-charg,
END OF t_ab_charg.
LOOP AT t_caufv.
SELECT aufnr charg FROM afpo INTO t_ab_charg WHERE aufnr =
t_caufv-aufnr.
APPEND t_ab_charg.
CLEAR t_ab_charg.
ENDSELECT.
ENDLOOP.
IF sy-subrc = 0.
SELECT * FROM afpo INTO TABLE itab_afpo WHERE charg = d_ab_charg.
ENDIF.
LOOP AT t_ab_charg.
SELECT * FROM afpo INTO itab_afpo WHERE charg = t_ab_charg-charg.
APPEND itab_afpo.
CLEAR itab_afpo.
ENDSELECT.
ENDLOOP.
CLEAR t_caufv.
REFRESH t_caufv.
*Get all the orders with the same batch number.
LOOP AT itab_afpo.
SELECT aufnr werks objnr gamng rsnum plnbez
INTO CORRESPONDING FIELDS OF
t_caufv FROM caufv WHERE aufnr = itab_afpo-aufnr.
APPEND t_caufv.
ENDSELECT.
ENDLOOP.
CLEAR t_caufv.
SORT t_caufv BY aufnr.
delete adjacent duplicates from t_caufv comparing all fields.
ENDIF.
SELECT aufnr posnr wemng amein charg INTO TABLE t_afpo
FROM afpo FOR ALL ENTRIES IN t_caufv
WHERE aufnr = t_caufv-aufnr.
d_returncode = sy-subrc.
IF d_returncode NE 0.
STOP.
ENDIF.
SORT t_afpo BY aufnr.
ENDFORM. " Z_SELECT_PROD_ORDERS
*& Form Z_SELECT_MAT_DESC
text
--> p1 text
<-- p2 text
FORM z_select_mat_desc.
Get the Description of all materials
SELECT matnr maktx INTO TABLE t_makt FROM makt
FOR ALL ENTRIES IN t_caufv
WHERE matnr = t_caufv-plnbez
AND spras = sy-langu.
ENDFORM. " Z_SELECT_MAT_DESC
*& Form Z_PROCESS_DATA
text
--> p1 text
<-- p2 text
FORM z_process_data.
Process the data from all production orders and prepare the output
table for display appropriately
DATA: d_mbgbtr TYPE p DECIMALS 3,
loop_cnt TYPE i.
REFRESH t_outputtab.
LOOP AT t_caufv.
CLEAR t_outputtab.
MOVE-CORRESPONDING t_caufv TO t_outputtab.
CLEAR t_makt.
READ TABLE t_makt WITH KEY matnr = t_caufv-plnbez.
IF sy-subrc EQ 0.
MOVE t_makt-maktx TO t_outputtab-maktx.
ENDIF.
CLEAR t_afpo.
READ TABLE t_afpo WITH KEY aufnr = t_caufv-aufnr.
IF sy-subrc EQ 0.
MOVE: t_afpo-wemng TO t_outputtab-wemng,
t_afpo-amein TO t_outputtab-amein,
t_afpo-charg TO t_outputtab-charg.
ENDIF.
IF t_outputtab-gamng NE 0.
COMPUTE t_outputtab-yield =
( t_outputtab-wemng / t_outputtab-gamng ) * 100.
ENDIF.
APPEND t_outputtab.
ENDLOOP.
SORT t_production_costs BY objnr kstar.
LOOP AT t_production_costs.
AT NEW objnr.
CLEAR: d_mbgbtr, d_tabix, t_outputtab.
READ TABLE t_outputtab WITH KEY objnr = t_production_costs-objnr.
MOVE sy-tabix TO d_tabix.
" Add up the Raw Material and Manufacturing Conversion
" Costs from the previous stage production order
CLEAR loop_cnt .
LOOP AT t_suborders WHERE aufnr = t_outputtab-aufnr.
commented by anand bothra on 20/11/2003
ADD 1 TO loop_cnt.
IF loop_cnt > 1.
EXIT.
ENDIF.
LOOP AT t_production_costs1 WHERE objnr = t_suborders-objnr.
CASE t_production_costs1-kstar.
WHEN '0005000000' OR '0005010000'. " Raw Material Cost
BEGIN OF deletion VIP110703
ADD t_production_costs1-wkgbtr TO t_outputtab-totalrmcost.
END OF deletion VIP110703
ADD t_production_costs1-wkgbtr TO prev_totmatqty.
WHEN '0000500100'. " Manufacturing Conversion Cost
ADD t_production_costs1-wkgbtr TO prev_tot_mfgconv_cst.
BEGIN OF deletion VIP110703
ADD t_production_costs1-wkgbtr TO t_outputtab-mfgconvcost.
END OF deletion VIP110703
ENDCASE.
ENDLOOP.
BEGIN OF INSERTION VIP110703
READ TABLE t_production_costs INTO wa_production_costs
WITH KEY objnr = t_production_costs-objnr
matnr = wa_prev_outputtab-plnbez.
IF sy-subrc = 0.
IF ( wa_production_costs-mbgbtr NE
wa_prev_outputtab-wemng ) .
prev_totmatqty = ( prev_totmatqty /
wa_prev_outputtab-wemng ) *
wa_production_costs-mbgbtr.
prev_tot_mfgconv_cst = ( prev_tot_mfgconv_cst /
wa_prev_outputtab-wemng ) *
wa_production_costs-mbgbtr.
ENDIF.
ENDIF.
LOOP AT t_suborders_propcost
WHERE prevaufnr = wa_prev_outputtab-aufnr.
t_suborders_propcost-proprmcost = prev_totmatqty.
t_suborders_propcost-prop_mfg_convcost = prev_tot_mfgconv_cst
MODIFY t_suborders_propcost.
ENDLOOP.
clear: prev_totmatqty,
prev_tot_mfgconv_cst.
END OF INSERTION VIP110703
BEGIN OF INSERTION VIP111003
CLEAR: wa_prev_outputtab,
wa_production_costs.
READ TABLE t_outputtab INTO wa_prev_outputtab
WITH KEY aufnr = t_suborders-prevaufnr.
ratio = 1.
IF sy-subrc = 0.
READ TABLE t_production_costs INTO wa_production_costs
WITH KEY objnr = t_outputtab-objnr
matnr = wa_prev_outputtab-plnbez.
IF sy-subrc = 0.
IF ( wa_production_costs-mbgbtr NE
wa_prev_outputtab-wemng ) .
ratio = wa_production_costs-mbgbtr /
wa_prev_outputtab-wemng.
prev_totmatqty = ( prev_totmatqty /
wa_prev_outputtab-wemng ) *
wa_production_costs-mbgbtr.
prev_tot_mfgconv_cst = ( prev_tot_mfgconv_cst /
wa_prev_outputtab-wemng ) *
wa_production_costs-mbgbtr.
ENDIF.
ENDIF.
ENDIF.
LOOP AT t_suborders_propcost
WHERE prevaufnr = wa_prev_outputtab-aufnr
AND aufnr = t_outputtab-aufnr.
t_suborders_propcost-proprmcost = prev_totmatqty.
t_suborders_propcost-prop_mfg_convcost = prev_tot_mfgconv_cst.
MODIFY t_suborders_propcost.
ENDLOOP.
*Commented by Anand Bothra on 20/11/2003.
CLEAR: prev_totmatqty,
prev_tot_mfgconv_cst.
BEGIN OF INSERTION VIP111003
ENDLOOP.
ENDAT.
AT END OF kstar.
SUM.
CASE t_production_costs-kstar.
WHEN '0000500200'. " Packing Conversion Costs
t_outputtab-pkgconvcost = t_production_costs-wkgbtr.
WHEN '0005000500'. " Semi-Finished Cost/Quantity
MOVE t_production_costs-mbgbtr TO d_mbgbtr.
WHEN '0005050000' OR '0005050001' OR '0005050002'.
" Packing Mat Costs
ADD t_production_costs-wkgbtr TO t_outputtab-totalpmcost.
WHEN '0005000000' OR '0005010000'.
ADD t_production_costs-wkgbtr TO t_outputtab-totalrmcost.
WHEN '0000500100'. " Manufacturing Conversion Cost
ADD t_production_costs-wkgbtr TO t_outputtab-mfgconvcost.
ENDCASE.
ENDAT.
AT END OF objnr.
MOVE d_waers TO t_outputtab-waers.
Calculations for the Production Order
" Determine the RM Cost/Unit and Mfg Conv Cost/Unit
CLEAR t_afpo1.
READ TABLE t_afpo1 WITH KEY aufnr = t_outputtab-aufnr.
IF ( ( sy-subrc EQ 0 ) AND ( t_afpo1-wemng NE 0 ) ).
BEGIN OF insertion VIP110703
tmp_aufnr = t_production_costs-objnr+2(12).
LOOP AT t_suborders_propcost
WHERE aufnr = tmp_aufnr .
ADD t_suborders_propcost-proprmcost TO t_outputtab-totalrmcost
ADD t_suborders_propcost-prop_mfg_convcost TO
t_outputtab-mfgconvcost.
ENDLOOP.
END OF insertion VIP110703
BEGIN OF insertion VIP111003
CLEAR: t_suborders_propcost , tmp_aufnr.
READ TABLE t_suborders_propcost
WITH KEY aufnr = t_outputtab-aufnr.
IF sy-subrc = 0.
t_suborders_propcost-proprmcost =
t_suborders_propcost-proprmcost * ratio.
ADD t_suborders_propcost-proprmcost
TO t_outputtab-totalrmcost.
t_suborders_propcost-prop_mfg_convcost =
t_suborders_propcost-prop_mfg_convcost * ratio.
ADD t_suborders_propcost-prop_mfg_convcost
TO t_outputtab-mfgconvcost.
tmp_aufnr = t_suborders_propcost-prevaufnr.
bln_suborder = 'T'.
WHILE bln_suborder = 'T'.
CLEAR: t_suborders_propcost .
READ TABLE t_suborders_propcost
WITH KEY aufnr = tmp_aufnr.
IF sy-subrc = 0.
t_suborders_propcost-proprmcost =
t_suborders_propcost-proprmcost * ratio.
ADD t_suborders_propcost-proprmcost
TO t_outputtab-totalrmcost.
t_suborders_propcost-prop_mfg_convcost =
t_suborders_propcost-prop_mfg_convcost * ratio.
ADD t_suborders_propcost-prop_mfg_convcost
TO t_outputtab-mfgconvcost.
tmp_aufnr = t_suborders_propcost-prevaufnr.
ELSE.
bln_suborder = 'F'.
CLEAR tmp_aufnr.
ENDIF.
ENDWHILE.
ENDIF.
END OF insertion VIP111003
END OF deletion VIP110703
t_outputtab-mfgconvcost = ( t_outputtab-mfgconvcost /
t_afpo1-wemng ) * d_mbgbtr.
t_outputtab-totalrmcost = ( t_outputtab-totalrmcost /
t_afpo1-wemng ) * d_mbgbtr.
END OF deletion VIP110703
ENDIF.
IF t_outputtab-wemng NE 0.
t_outputtab-rmperunit = t_outputtab-totalrmcost /
t_outputtab-wemng.
" PM Cost Per Unit = Total PM Cost / Quantity Delivered
t_outputtab-pmperunit = t_outputtab-totalpmcost
/ t_outputtab-wemng.
" Conv Cost Cost Per Unit = (Manu Conv Cost + Pack Conv Cost)
" / Qty Delv
t_outputtab-ccperunit = ( t_outputtab-mfgconvcost
+ t_outputtab-pkgconvcost )
/ t_outputtab-wemng.
ENDIF.
" Total Cost Per Unit = (RM Cost per unit + PM Cost per Unit
" + Conv Cost per unit)
t_outputtab-totperunit = t_outputtab-rmperunit
+ t_outputtab-pmperunit
+ t_outputtab-ccperunit.
Update the calculated values in the internal table
CHECK d_tabix GT 0.
MODIFY t_outputtab INDEX d_tabix
TRANSPORTING totalrmcost totalpmcost
mfgconvcost pkgconvcost
rmperunit pmperunit
ccperunit totperunit waers.
BEGIN OF DELETION VIP110703
MOVE t_outputtab TO wa_prev_outputtab.
END OF DELETION VIP110703
ENDAT.
ENDLOOP.
ENDFORM. " Z_PROCESS_DATA
*& Form Z_DISPLAY_LIST
text
--> p1 text
<-- p2 text
FORM z_display_list.
Display the Report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
i_callback_program = d_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
is_layout = wa_listlayout
it_fieldcat = t_fieldcatalog
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = t_sortsequence
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = ' '
it_events = t_listevents
IT_EVENT_EXIT =
is_print = wa_print_info
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = t_outputtab
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SET PF-STATUS 'Z_AB_STANDARD'.
ENDFORM. " Z_DISPLAY_LIST
*& Form Z_FILL_FIELDCATALOG
text
--> p1 text
<-- p2 text
FORM z_fill_fieldcatalog USING p_rownum LIKE sy-curow
p_colnum LIKE sy-cucol
p_fieldname TYPE slis_fieldname
p_tabname TYPE slis_tabname
p_reffield TYPE dd03p-fieldname
p_reftable TYPE dd03p-tabname
p_qfield TYPE slis_fieldname
p_qtab TYPE slis_tabname
p_sum
p_stext
p_mtext
p_ltext
p_datatype
p_outputlen.
Prepare the fields for ALV list output
CLEAR wa_fieldcatalog.
wa_fieldcatalog-row_pos = p_rownum.
wa_fieldcatalog-col_pos = p_colnum.
wa_fieldcatalog-fieldname = p_fieldname.
wa_fieldcatalog-tabname = p_tabname.
wa_fieldcatalog-ref_fieldname = p_reffield.
wa_fieldcatalog-ref_tabname = p_reftable.
wa_fieldcatalog-qfieldname = p_qfield.
wa_fieldcatalog-qtabname = p_qtab.
wa_fieldcatalog-do_sum = p_sum.
wa_fieldcatalog-seltext_s = p_stext.
wa_fieldcatalog-seltext_m = p_mtext.
wa_fieldcatalog-seltext_l = p_ltext.
wa_fieldcatalog-datatype = p_datatype.
wa_fieldcatalog-outputlen = p_outputlen.
APPEND wa_fieldcatalog TO t_fieldcatalog.
ENDFORM. " Z_FILL_FIELDCATALOG
*& Form Z_PREPARE_FIELDCAT
text
--> p1 text
<-- p2 text
FORM z_prepare_fieldcat.
Append all the display fields into the field catalog internal table
First Row
PERFORM z_fill_fieldcatalog USING 1 1 'PLNBEZ' 'T_OUTPUTTAB'
space 'AFKO' space space
space space space space space
0.
PERFORM z_fill_fieldcatalog USING 1 2 'MAKTX' 'T_OUTPUTTAB'
space 'MAKT' space space
space space space space space
0.
PERFORM z_fill_fieldcatalog USING 1 3 'CHARG' 'T_OUTPUTTAB'
space 'AFPO' space space
space space space space space
0.
Second Row
PERFORM z_fill_fieldcatalog USING 2 1 'AUFNR' 'T_OUTPUTTAB'
space 'AFKO' space space
space space space space space
0.
PERFORM z_fill_fieldcatalog USING 2 2 'GAMNG' 'T_OUTPUTTAB'
space 'CAUFV' 'AMEIN' space
'X' space space space space
0.
PERFORM z_fill_fieldcatalog USING 2 3 'WEMNG' 'T_OUTPUTTAB'
space 'AFPO' 'AMEIN' space
'X' space space space space
0.
PERFORM z_fill_fieldcatalog USING 2 4 'AMEIN' 'T_OUTPUTTAB'
space 'AFPO' space space
space space space space space
0.
PERFORM z_fill_fieldcatalog USING 2 5 'YIELD' 'T_OUTPUTTAB'
space space space space
space text-010 text-010 text-010
'QUAN' 17.
Third Row
PERFORM z_fill_fieldcatalog USING 3 1 'TOTALRMCOST' 'T_OUTPUTTAB'
space space space space
'X' text-011 text-011 text-011
'CURR' 21.
PERFORM z_fill_fieldcatalog USING 3 2 'TOTALPMCOST' 'T_OUTPUTTAB'
space space space space
'X' text-012 text-012 text-012
'CURR' 21.
PERFORM z_fill_fieldcatalog USING 3 3 'MFGCONVCOST' 'T_OUTPUTTAB'
space space space space
'X' text-013 text-013 text-013
'CURR' 21.
PERFORM z_fill_fieldcatalog USING 3 4 'PKGCONVCOST' 'T_OUTPUTTAB'
space space space space
'X' text-014 text-014 text-014
'CURR' 21.
Fourth Row
PERFORM z_fill_fieldcatalog USING 4 1 'RMPERUNIT' 'T_OUTPUTTAB'
space space space space
space text-015 text-015 text-015
'CURR' 21.
PERFORM z_fill_fieldcatalog USING 4 2 'PMPERUNIT' 'T_OUTPUTTAB'
space space space space
space text-016 text-016 text-016
'CURR' 21.
PERFORM z_fill_fieldcatalog USING 4 3 'CCPERUNIT' 'T_OUTPUTTAB'
space space space space
space text-017 text-017 text-017
'CURR' 21.
PERFORM z_fill_fieldcatalog USING 4 4 'TOTPERUNIT' 'T_OUTPUTTAB'
space space space space
space text-018 text-018 text-018
'CURR' 21.
ENDFORM. " Z_PREPARE_FIELDCAT
*& Form Z_GET_ALV_EVENTS
text
--> p1 text
<-- p2 text
FORM z_get_alv_events.
Returns table of possible events for a list type
REFRESH t_listevents.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
et_events = t_listevents
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
CLEAR: wa_listevents, d_tabix.
READ TABLE t_listevents WITH KEY name = slis_ev_top_of_page
INTO wa_listevents.
d_tabix = sy-tabix.Hi Sai,
You can try using MB51, use filter movement type 261. Add a filter for the posting date coverage.
Then proceed. Click on the icon DETAIL LIST.
Then click on the SUBTOTAL, add MATERIAL as a Criteria. The click the column AMOUNT IN LC.
You should see the total issuances to per material.
I hope this helps.
Heinrick Palad -
Excise Duties should be added to the material cost
Hi all,
Here my Client place comes under excise exception. Here they are not going to avail excise credit. Also there is no utilization. If the material is procured from outside then the vendor will charge the excise amount as he comes under excisable place. So in this case my client wants to track the excise duties paid on the materials and they want the register updation also. Meanwhile they want the excise duties to be added on the Material cost. So I have maintained J1ID settings for the materials & vendors also I have maintained FV11. Here in this case the excise duties are not adding up to material cost.
For Ex: I am procuring a Material ABC from a Vendor. My PO price will be 100.
Qty=1EA
PO Price=100
BED=16
Ecess=0.32
SEcess=0.16
In Normal case my Inventory cost of the material will be 100.
In this case my client wants to be 116.48 should be the material price and at the same time the 16,0.32&0.16 should post to the respective CENVAT Clearing account at the time of MIGO & MIRO.
Can anyone please suggest me how to handle this issue?hi Manju
As i understood that your plant is in the area which is under Tax exempted. See you have two option from excise point of view.
1. Either mantain the conditions through FV11 and call the same in your PO through Tax code and country combination.
Mantain the J1ID and manatain material chapter id combination material type and the no of gr and credit allowed it will hit your excise register in migo while you do GR as per the material type mantained in J1ID. But here you cant add the duty amount to be get added on Material Value.
2. You mantain the condtion in the FV11 go for key combination tax code and country, inventorised condition type for eg JMIP inv BED condtion mantain the desirable rate their which would be 14% from now. Create PO with the suitable tax code and mantain J1ID AND DO THE GR IT WILL GET ADDED TO YOUR MATERIAL VALUE.
Also if you cant avail the credit on the output material you cant accumalate credit in your register also accumulated credit can't be carry forward in the next financial year.
Reward if usefull
Regards
Sujoy -
Error in Distribution of Actual cost in Cost Object Hierarchy
Hi,
I am getting an error while doing the Distribution of Actual cost from Cost Object Node to the assigned Order.
Cost element/origin 630000 could not be distributed
Message no. KZ468
Diagnosis
The cost element/ origin 630000 could not be distributed because there are no target costs for this cost element/origin or for cost element group CO-PC-TOT.
Procedure
Check the calculated target costs and cost element group CO-PC-TOT assigned to the target cost version.
Procedure for System Administration
Proceed
Although the Cost element is Present in cost element group CO-PC-TOT.
One more information, the order that is assigned in Cost Object Hierarchy is of CO-Product orders.
I have searched in the forum but I havent got any solution.
Kindly help.
regards
KamiHi,
Concerning error message KZ 468, it has the following origin: In the customizing of the cost object category (transaction okz5), check if the 'single object selection' is set to 'Control through variance key'. If you consider the F1-Help for this option you will find the following explanation:
if the indicator Control through variance key is turned on, the production order, process order, or product cost collector can only be assigned to the cost object hierarchy if:
-> The material is assigned to the lowest node of the hierarchy
-> No variance key is specified in the order
The important point is, that orders that have a variance key are excluded from the cost distribution.
In transaction KKF8 you will find that all these orders do indeed have a variance key. Hence, all of these orders are included, there are no target costs from the orders and the costs cannot be distributed. Thus the error message kz 468.
Please consider that and check the customizing again.
Not having target costs in the distribution indicates either a wrong set up of the hierarchy or, more likely, no valid cost estimate for a certain material of a production order or product cost collector could be found.
Did you check whether for this cost element/origin target costs exist, and also for the cost element group? If not the message KZ468 is correct and probably the cost element group has to be maintained properly.
The distribution of actual costs calculates target costs on-the-fly and the variance calculation does not have to be carried out before. Quite the opposite than the variance calculation requires the distribution as a preceding step. Furthermore it is not sufficient that one cost element is in a cost element group but the interval where the cost element has been assigned to has to have some target costs. Otherwise this won't work and message KZ468 is issued.
regards
Waman -
Assign direct material cost to value field in copa while issue to Prod orde
Dear All,
My requirement is like this:
There are some 16 material groups from A to P each containing some materials(finished goods).
I want to allocate overhead to different material groups(Charecteristic in copa) in COPA using the periodic assesment cycles. I am able to allocate overhead(admin & sales cost) to different value fields in copa from different cost centers.
I want to analyse the product cost and also the profitability of each material group in COPA using Report painter. Iam able to pull all the costs which i assign to value fields using assessment. But, i am NOT able to get the direct material cost which is issued to production orders using BOM.
My question is whether we can assign the direct material cost to any user defined value field(material cost value field) while the material is being issued to production orders. Is there any automated way where we can directly assign the direct material cost to value field in copa while issuing the material to Production orders.
Pls explain me whether we can do it. if yes how?
Thank you very much in advance.
Regards,
Vishnu
VST-IT.PA is a Profitability analysis tool. That means it gets updated when a sale is made, not before. (Except for settlements and assessment of overheads.)
Goods issues for production gets updated in CO-PC, and needs to be analysed there. If you don't, you loose all the inbuilt tools for variance analysis, cost estimate comparisons, Wip Calculation etc. To the best of my knowledge, a Profitability Segment cannot be used as a cost object in Production Planning, because amongst others, you need to be able to capitalise the produced materials to stock at the end of the production run, or to WIP at the end of the Financial period,which is not possible with PS.
Similarly, overheads are recorded in CCA and needs to be analysed there.
If one goes against these big groupings in SAP, you always run into problems. -
How to Update material cost of user defined org specific cost type
Hi,
We need to update material cost sub elements of an item for an org specific and user defined cost type.
I have inserted a sample row in the CST_ITEM_CST_DTLS_INTERFACE, and running open interface 'Mass Update Material Costs', but the program is not at all processing the rows, the Process_flag remains 1.
insert into cst_item_cst_dtls_interface
(inventory_item_id,
organization_id,
resource_id,
usage_rate_or_amount,
cost_element_ID,
Process_Flag ,
last_update_date,
last_updated_by,
creation_date,
created_by
values
(96023,
343,
52538,
0.00208012,
1,
1,
sysdate,
fnd_global.user_id,
sysdate,
fnd_global.user_id
Can someone help me out with this, thanks.
Regards
DasuI think there is some confusion.
"Mass Edit Material Costs" program is used to apply new activity rates to item costs. For this, you don't have to insert records in the interface. You have to define/update the new activity rates using screen.
To process records in the cost interface tables, you have to run the "Cost Import Process" program.
For more details, refer to http://download.oracle.com/docs/cd/A60725_05/html/comnls/us/cst/settas06.htm
Hope this answers your question
Sandeep Gandhi
Omkar Technologies Inc.
Independent Techno-functional Consultant
Maybe you are looking for
-
Cannot save form with Windows Vista and Adobe Reader 8
I have many forms created with Adobe Livecycle Designer 8. Users who have upgraded to Windows Vista can no longer save these forms. Any ideas? thanks.
-
I bourght "E O Wilson's Life on Earth" and backed it up to my iMac. Now it won't sync back to my iPad because it says I don't have permission on this computer. I don't want to download it from iTunes again because it took up a lot of bandwidth. What'
-
Why can we not pre-order the Iphone 4 due to tech problems? The US seams ok
I have been trying to pre-Oreder the new Iphone and I have had no joy. For over an hour now the uk web page has had problems. I do not think is fair how other webpages on other countries like the US have no problem on making orders but the uk for som
-
Cameras for filming??
I recently got into FCPX and ive been filming a lot but ive noticed something that must be obvious to anyone with any sort of experience. The camera i use does not provide good quality video. Can someone suggest a good camera, which can record from a
-
ABAP OOP method in Workflow task 6.20
Hello all! In the following blog /people/jocelyn.dart/blog/2006/07/25/using-abap-oo-methods-in-workflow-tasks it is mentionned that to enable OOP methods for workflow tasks on 6.20 one needs to run report SWF_CATID. I'm currently on a customer system