Datum validation
Hi,
Can anyone help me how to write a validation on date to check if inserting the iten is a date and when not a error message should appear??
Hi,
ekas wrote:
Hi,
Can anyone help me how to write a validation on date to check if inserting the iten is a date and when not a error message should appear??Sorry, it's unclear what you're asking.
What front end are you using? Most tools have a way to specify DATE fields, where you give the expected format, and the front end gives an error if the input isn't valid.
In pure SQL, you can use TO_DATE; it will raise an error if you pass it an invalid string.
If you need some way of detecting whether the string is invalid without raising an Oracle error, see this thread:
Re: how to select valid dates only
Similar Messages
-
Need description & table name of following field
Hi,
I came across following fields, but not aware of decription & table name.
KSCHL
VKORGAU
VKORG
PSTYV
DATAB
DATBI
please any one can give me description or field name of above fields.
Regards,KSCHL - Condition Type
Data Type CHAR Character String
Length 4 Decimal Places 0
VKORG - Sales Organization
Data Type CHAR Character String
Length 4 Decimal Places 0
PSTYV - Sales document item category
Data Type CHAR Character String
Length 4 Decimal Places 0
DATUM - Valid-From Date
Data Type DATS Date field (YYYYMMDD) stored
Length 8 Decimal Places 0
DATUM - Valid to Date
Data Type DATS Date field (YYYYMMDD) stored
Length 8 Decimal Places 0
You can check more information about them at SE11 placing them at the Table Field.
There you can see the "Where used" key that will show you where they are used (probably many tables...)
Good Luck !
Plauto
Edited by: Plauto Abreu on Feb 25, 2011 9:23 PM -
How can the ALV display more than 100 chars?
Hi,
I'm developing a ALV using ABAP Object, my problem is that I need that the ALV shows unless 1024 chars but it only shows 100.
I have the followind code to create the container and the ALV grid:
CREATE OBJECT v_o_container
EXPORTING
container_name = c_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
CREATE OBJECT v_o_alvgrid
EXPORTING
i_parent = v_o_container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
CALL METHOD v_o_alvgrid->set_table_for_first_display
EXPORTING
i_structure_name = c_structure
is_layout = x_layout
CHANGING
it_outtab = i_alv_data
it_fieldcatalog = i_catalog
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Could anyone, please, tell me if I need anymore to show more char?
Thank you very much.DATA: BEGIN OF i_alv_data OCCURS 0,
pernr LIKE p0001-pernr, "personnel number
icnum LIKE p0185-icnum, "personal ID
vorna LIKE p0002-vorna, "First name
nachn LIKE p0002-nachn, "Last name
sachn LIKE t526-sachn, "PersAdmin
sachn2 LIKE t526-sachn, "Business Partner G
text_persg LIKE t501t-ptext, "Employee group
text_persk LIKE t503t-ptext, "Employee subgroup
stext2 LIKE hrp1000-stext, "position
stext1 LIKE hrp1000-stext, "department
text_werks LIKE t500p-name1, "Location
text_trfgb LIKE t510g-tgbtx, "PS type
trfgr LIKE p0008-trfgr, "diageo band
trfst LIKE p0008-trfst, "Local grade
lm_name LIKE p0001-ename, "line manager name
datfr LIKE sy-datum, "Validity from
datto LIKE sy-datum, "Validity to
comp_stat LIKE dd07t-ddtext, "Completion Status
mobilitx TYPE string, "mobility text
cab_continue TYPE string, "My Capab.and
cab_start TYPE string, "My Capab.and Be
nco1 TYPE string, "Posib next car op
nco2 TYPE string, "Posi next car opt
nco3 TYPE string, "Pos next carop
timing3 LIKE i_hap_t_body_cells-value_text,
epcm TYPE string, "Employee Commitme
mpcm TYPE string, "Manager commitmen
END OF i_alv_data. -
Hi All,
I got a requirement regarding data transfer using bapi's. can anyone please tell me how to create a bapi.
please send me any program to understand better.
Reward points will be given for best answer.
thanx in advanceHi,
Welcome to SDN.
Refer https://forums.sdn.sap.com/click.jspa?searchID=5436713&messageID=1715433 why bapi used insted of bdc?
check the below sample program using bapi..
REPORT z_po_create NO STANDARD PAGE HEADING
MESSAGE-ID z0lo_scm
LINE-SIZE 220
LINE-COUNT 65 .
TABLES : ekko,
ekpo.
D A T A D E C L A R A T I O N S
*--Type declaration to store data read from table EKKO.
TYPES : BEGIN OF t_ekko,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bsart TYPE ekko-bsart,
aedat TYPE ekko-aedat,
ernam TYPE ekko-ernam,
lifnr TYPE ekko-lifnr,
ekorg TYPE ekko-ekorg,
ekgrp TYPE ekko-ekgrp,
spras TYPE ekko-spras,
werks TYPE ekpo-werks,
END OF t_ekko.
*--Type declaration to store data read from table EKPO.
TYPES : BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
lgort TYPE ekpo-lgort,
menge TYPE ekpo-menge,
knttp TYPE ekpo-knttp,
matkl TYPE ekpo-matkl,
bednr TYPE ekpo-bednr,
afnam TYPE ekpo-afnam,
meins TYPE ekpo-meins,
bpumz TYPE ekpo-bpumz,
bpumn TYPE ekpo-bpumn,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
webaz TYPE ekpo-webaz,
END OF t_ekpo.
TYPES : BEGIN OF t_head_item,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bsart TYPE ekko-bsart,
aedat TYPE ekko-aedat,
ernam TYPE ekko-ernam,
lifnr TYPE ekko-lifnr,
ekorg TYPE ekko-ekorg,
ekgrp TYPE ekko-ekgrp,
spras TYPE ekko-spras,
pincr TYPE ekko-pincr,
zterm TYPE ekko-zterm,
waers TYPE ekko-waers,
inco1 TYPE ekko-inco1,
inco2 TYPE ekko-inco2,
bedat TYPE ekko-bedat,
ebelp TYPE ekpo-ebelp,
txz01 TYPE ekpo-txz01,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
lgort TYPE ekpo-lgort,
menge TYPE ekpo-menge,
knttp TYPE ekpo-knttp,
matkl TYPE ekpo-matkl,
bednr TYPE ekpo-bednr,
afnam TYPE ekpo-afnam,
meins TYPE ekpo-meins,
bpumz TYPE ekpo-bpumz,
bpumn TYPE ekpo-bpumn,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
webaz TYPE ekpo-webaz,
mwskz TYPE ekpo-mwskz,
adrn2 TYPE ekpo-adrn2,
END OF t_head_item.
TYPES : BEGIN OF t_sucess,
ebeln TYPE ekko-ebeln,
END OF t_sucess.
TYPES : BEGIN OF t_ekko_ekpo,
ebeln TYPE ekko-ebeln,
lifnr TYPE ekko-lifnr,
inco1 TYPE ekko-inco1,
inco2 TYPE ekko-inco2,
zterm TYPE ekko-zterm,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
END OF t_ekko_ekpo.
TYPES: BEGIN OF t_err_log,
ebeln TYPE ebeln, " Purchase order no.
bstpo TYPE bstpo, " Purchase order line item
etenr TYPE etenr, " Schedule line
err_val(20) TYPE c, " Error value
err_msg(100) TYPE c, " Error message
pogr_err(1) TYPE c, " If 'X' indicates PO creation error,
" else, indicates GR creation error
END OF t_err_log.
*-- Variables declarations.
DATA : v_ebeln TYPE ekko-ebeln, "PO Number
v_bsart TYPE ekko-bsart,
v_ekorg TYPE ekko-ekorg, "Purchasing Organization
v_ekgrp TYPE ekko-ekgrp, "Purchasing group
v_lifnr TYPE ekko-lifnr, "Vendor Number
v_werks TYPE ekpo-werks, "Plant
v_matnr TYPE ekpo-matnr, "Material Number
v_infnr TYPE ekpo-infnr. "Agreement
*-- Constants declarations.
CONSTANTS: c_bstyp TYPE ekpo-bstyp VALUE 'K',
c_bstyp1 TYPE ekpo-bstyp VALUE 'F',
c_x VALUE 'X'.
D A T A D E C L A R A T I O N S FOR BAPI
**-BAPI structure for Purchase Order Header Data
DATA : x_poheader TYPE bapimepoheader,
**-BAPI structure for Purchase Order Header Data (Change Toolbar)
x_poheaderx TYPE bapimepoheaderx,
**-BAPI structure for Purchase Order Item Data
x_poitem TYPE bapimepoitem,
**-BAPI structure for Purchase Order Item Data (Change Toolbar)
x_poitemx TYPE bapimepoitemx,
**-BAPI structure for messages
x_return TYPE bapiret2,
**-Structure for the error log
x_err_log TYPE t_err_log,
**-BAPI structure for Purchase Order Account assignment Data
x_poaccount TYPE bapimepoaccount,
**-BAPI structure for Purchase Order Account assignment
**-Data (Change Toolbar)
x_poaccountx TYPE bapimepoaccountx,
*ADDRESS
x_deliveryaddr TYPE bapimepoaddrdelivery.
**-BAPI internal table containing purchase order item
DATA : it_poitem TYPE STANDARD TABLE OF bapimepoitem,
**-BAPI internal table containing PO item data (Change Toolbar)
it_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
**-BAPI Return table containing messages
it_return TYPE STANDARD TABLE OF bapiret2,
**-BAPI internal table containing Account Assignment Fields for PO
it_poaccount TYPE STANDARD TABLE OF bapimepoaccount,
**-BAPI internal table containing Account Assignment Fields
**-in Purchase Order (Change Toolbar)
it_poaccountx TYPE STANDARD TABLE OF bapimepoaccountx,
it_deliveryaddr TYPE STANDARD TABLE OF bapimepoaddrdelivery.
I N T E R N A L T A B L E D E C L E R A T I O N S
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko WITH HEADER LINE,
it_ekko_dest TYPE STANDARD TABLE OF t_ekko WITH HEADER LINE,
it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE,
it_head_item TYPE STANDARD TABLE OF t_head_item WITH HEADER LINE,
it_ekko_ekpo TYPE STANDARD TABLE OF t_ekko_ekpo WITH HEADER LINE,
it_sucess TYPE STANDARD TABLE OF t_sucess WITH HEADER LINE,
it_contract TYPE STANDARD TABLE OF t_sucess WITH HEADER LINE,
**-Internal table containing error messages
it_err_log TYPE STANDARD TABLE OF t_err_log.
S E L E C T I O N S C R E E N
*-- Selection criteria
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:s_ebeln FOR ekko-ebeln, "PO Number
s_bsart FOR ekko-bsart DEFAULT 'ZHBV', "PO Type
s_aedat FOR ekko-aedat DEFAULT sy-datum, "Creation Date
s_ekorg FOR ekko-ekorg, "Purchasing Organization
s_ekgrp FOR ekko-ekgrp, "Purchasing group
s_lifnr FOR ekko-lifnr, "Vendor Number
s_werks FOR ekpo-werks, "Plant
s_matnr FOR ekpo-matnr, "Material Number
s_infnr FOR ekpo-infnr. "Agreement
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS :p_bukrs LIKE ekko-bukrs DEFAULT '9040', "Company Code
p_werks LIKE ekpo-werks DEFAULT '7040', "Plant
p_ekorg LIKE ekko-ekorg DEFAULT '9040', "Purchasing Organization
p_ekgrp LIKE ekko-ekgrp DEFAULT '031', "Purchasing group
p_bsart1 LIKE ekko-bsart DEFAULT 'ZHIH'. "PO Type
SELECTION-SCREEN END OF BLOCK b2.
A T S E L E C T I O N - S C R E E N
AT SELECTION-SCREEN.
*-- Validating the Selection Screen inputs.
PERFORM validate_user_input.
S T A R T - O F - S E L E C T I O N
START-OF-SELECTION.
*-- Getting data from table EKKO.
PERFORM get_purchase_order.
*-- Getting data from table EKKO
PERFORM get_po_created.
*-- Getting data from table EKKO & EKPO
PERFORM get_contract_num.
*-- Creating the PO.
PERFORM create_po.
E N D - O F - S E L E C T I O N
END-OF-SELECTION.
*-- Display PO which are already created
PERFORM display_createdpo_rept.
*-- Display PO which doesnt have contract numbers
PERFORM display_contract_rept.
TOP-OF-PAGE.
PERFORM page_heading.
*& Form VALIDATE_USER_INPUT
Form to validate user inputs at Selection Screen.
FORM validate_user_input .
*-- Validating Purchasing Document Number
IF NOT s_ebeln[] IS INITIAL.
SELECT ebeln
INTO v_ebeln
FROM ekko
UP TO 1 ROWS
WHERE ebeln IN s_ebeln.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Document Number'(004).
ENDIF.
ENDIF.
*-- Validating Purchasing Document Type
IF NOT s_bsart[] IS INITIAL.
SELECT bsart
INTO v_bsart
FROM t161
UP TO 1 ROWS
WHERE bsart IN s_bsart.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Document Type'(005).
ENDIF.
ENDIF.
*-- Validating Purchasing org
IF NOT s_ekorg[] IS INITIAL.
SELECT ekorg
INTO v_ekorg
FROM t024e
UP TO 1 ROWS
WHERE ekorg IN s_ekorg.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Organization'(006).
ENDIF.
ENDIF.
*-- Validating Purchasing group
IF NOT s_ekgrp[] IS INITIAL.
SELECT ekgrp
INTO v_ekgrp
FROM t024
UP TO 1 ROWS
WHERE ekgrp IN s_ekgrp.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Group'(007).
ENDIF.
ENDIF.
*-- Validating Vendor's account number
IF NOT s_lifnr[] IS INITIAL.
SELECT lifnr
INTO v_lifnr
FROM lfa1
UP TO 1 ROWS
WHERE lifnr IN s_lifnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Vendor account number'(008).
ENDIF.
ENDIF.
*-- Validating Plant
IF NOT s_werks[] IS INITIAL.
SELECT werks
INTO v_werks
FROM t001w
UP TO 1 ROWS
WHERE werks IN s_werks.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Plant'(009).
ENDIF.
ENDIF.
*-- Validating Material
IF NOT s_matnr[] IS INITIAL.
SELECT matnr
INTO v_matnr
FROM mara
UP TO 1 ROWS
WHERE matnr IN s_matnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Material Number'(010).
ENDIF.
ENDIF.
*-- Validating info record(Agreement)
IF NOT s_infnr[] IS INITIAL.
SELECT infnr
INTO v_infnr
FROM eina
UP TO 1 ROWS
WHERE infnr IN s_infnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid purchasing info record'(011).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_USER_INPUT
*& Form GET_PURCHASE_ORDER
Form to fetch data required from table EKKO & EKPO into internal table.
FORM get_purchase_order.
REFRESH it_head_item.
*-- Getting data from table EKKO & EKPO.
SELECT a~ebeln
a~bukrs
a~bsart
a~aedat
a~ernam
a~lifnr
a~ekorg
a~ekgrp
a~spras
a~pincr
a~zterm
a~waers
a~inco1
a~inco2
a~bedat
b~ebelp
b~txz01
b~matnr
b~werks
b~lgort
b~menge
b~knttp
b~matkl
b~bednr
b~afnam
b~meins
b~bpumz
b~bpumn
b~netpr
b~peinh
b~webaz
b~mwskz
b~adrn2
INTO TABLE it_head_item
FROM ekko AS a
INNER JOIN ekpo AS b
ON aebeln = bebeln
WHERE a~ebeln IN s_ebeln
AND a~bsart IN s_bsart
AND a~aedat IN s_aedat
AND a~ekgrp IN s_ekgrp
AND a~ekorg IN s_ekorg
AND a~lifnr IN s_lifnr
AND a~loekz <> c_x
AND b~werks IN s_werks
AND b~matnr IN s_matnr
AND b~infnr IN s_infnr
AND b~loekz <> c_x.
IF sy-subrc = 0.
SORT it_head_item BY ebeln.
LOOP AT it_head_item.
it_head_item-ebeln+0(1) = 'I'.
MODIFY it_head_item INDEX sy-tabix.
ENDLOOP.
ELSE.
MESSAGE i000 WITH 'No Purchase Order is possible for creation'(003).
STOP.
ENDIF.
ENDFORM. " GET_PURCHASE_ORDER
*& Form GET_PO_CREATED
Form to fetch data required from table EKKO into internal table.
Delete those records which are already created
FORM get_po_created .
*--fetch data from table EKKO into internal table
*--Where Docu type = 'ZHIH'
IF NOT it_head_item[] IS INITIAL.
SELECT a~ebeln
a~bukrs
a~bsart
a~aedat
a~ernam
a~lifnr
a~ekorg
a~ekgrp
a~spras
b~werks
INTO TABLE it_ekko_dest
FROM ekko AS a
INNER JOIN ekpo AS b
ON aebeln = bebeln
FOR ALL ENTRIES IN it_head_item
WHERE a~ebeln = it_head_item-ebeln
AND a~bsart = p_bsart1
AND a~bukrs = p_bukrs
AND b~werks = p_werks
AND b~bstyp = c_bstyp1
AND a~ekorg = p_ekorg
AND a~ekgrp = p_ekgrp.
IF sy-subrc = 0.
SORT it_ekko_dest BY ebeln.
ENDIF.
ENDIF.
*--Move all the PO numbers into sucess internal table
*--if the PO was already created
LOOP AT it_ekko_dest.
MOVE it_ekko_dest-ebeln TO it_sucess-ebeln.
APPEND it_sucess.
CLEAR it_sucess.
DELETE it_head_item WHERE ebeln = it_ekko_dest-ebeln.
ENDLOOP.
CLEAR it_head_item.
IF it_head_item[] IS INITIAL.
MESSAGE i000 WITH 'No Purchase Order is possible for creation'(003).
STOP.
ENDIF.
ENDFORM. " GET_PO_CREATED
*& Form GET_CONTRACT_NUM
text
FORM get_contract_num .
*--Select the data to get contract number
IF NOT it_head_item[] IS INITIAL.
SELECT a~ebeln "contract numbers
a~lifnr
a~inco1 "Incoterm1
a~inco2 "incoterm2
a~zterm
b~ebelp
b~matnr
INTO TABLE it_ekko_ekpo
FROM ekko AS a
INNER JOIN ekpo AS b
ON a~ebeln = b~ebeln
FOR ALL ENTRIES IN it_head_item
WHERE b~matnr = it_head_item-matnr
AND a~bukrs = p_bukrs " Company code
AND a~ekorg = p_ekorg " Purchase org
AND a~loekz <> c_x " Deletion indicator for header data
AND a~kdatb <= sy-datum " Validity period start
AND a~kdate >= sy-datum " Validity period end
AND b~loekz <> c_x " Deletion indicator for item data
AND b~bstyp = c_bstyp. " Purch. doc. category
IF sy-subrc = 0.
SORT it_ekko_ekpo BY matnr.
ENDIF.
LOOP AT it_head_item.
READ TABLE it_ekko_ekpo WITH KEY matnr = it_head_item-matnr
BINARY SEARCH.
IF sy-subrc <> 0.
*-- move the data to the internal table
*-- which doesnt have contract number
it_contract-ebeln = it_head_item-ebeln.
APPEND it_contract.
CLEAR it_contract.
*-- Deleting the record
*-- which doesnt have any contract number
DELETE it_head_item WHERE ebeln = it_head_item-ebeln.
ENDIF.
ENDLOOP.
CLEAR it_head_item.
ENDIF.
IF it_head_item[] IS INITIAL.
MESSAGE i000 WITH 'No Purchase Order is possible for creation'(003).
STOP.
ENDIF.
ENDFORM. " GET_CONTRACT_NUM
*& Form CREATE_PO
CREATE PURCHASE ORDER
FORM create_po .
DATA: l_ret_msg(1000) TYPE c. " Success/Error message from BAPI
CLEAR: x_poheader, x_poheaderx.
SORT it_head_item BY ebeln.
LOOP AT it_head_item.
AT NEW ebeln.
READ TABLE it_head_item WITH KEY ebeln = it_head_item-ebeln.
IF sy-subrc = 0.
**-Populate PO Header structure
x_poheader-po_number = it_head_item-ebeln. " PO no.
x_poheader-comp_code = p_bukrs. " Company code
x_poheader-doc_type = p_bsart1. " Document type
x_poheader-creat_date = it_head_item-aedat. " Date created
x_poheader-created_by = it_head_item-ernam. " Created by
READ TABLE it_ekko_ekpo WITH KEY matnr = it_head_item-matnr
BINARY SEARCH.
IF sy-subrc = 0.
x_poheader-vendor = it_ekko_ekpo-lifnr. " Vendor no.
x_poheader-incoterms1 = it_ekko_ekpo-inco1. " Incoterms1
x_poheader-incoterms2 = it_ekko_ekpo-inco2. " Incoterms2
x_poheader-pmnttrms = it_ekko_ekpo-zterm. " Payment terms
ENDIF.
x_poheader-langu = sy-langu. " Language key
x_poheader-langu_iso = sy-langu. " Language key iso
x_poheader-purch_org = p_ekorg. " Purchasing org.
x_poheader-pur_group = p_ekgrp. " Purch. Group
x_poheader-currency = it_head_item-waers. " currency
x_poheader-currency_iso = it_head_item-waers. " currency iso
x_poheader-doc_date = it_head_item-bedat. " Doc date
**-Populate PO Header 'X' structure
x_poheaderx-po_number = c_x.
x_poheaderx-comp_code = c_x.
x_poheaderx-doc_type = c_x.
x_poheaderx-creat_date = c_x.
x_poheaderx-created_by = c_x.
x_poheaderx-vendor = c_x.
x_poheaderx-langu = c_x.
x_poheaderx-langu_iso = c_x.
x_poheaderx-pmnttrms = c_x.
x_poheaderx-purch_org = c_x.
x_poheaderx-pur_group = c_x.
x_poheaderx-currency = c_x.
x_poheaderx-currency_iso = c_x.
x_poheaderx-doc_date = c_x.
x_poheaderx-incoterms1 = c_x.
x_poheaderx-incoterms2 = c_x.
ENDIF.
ENDAT.
READ TABLE it_ekko_ekpo WITH KEY matnr = it_head_item-matnr
BINARY SEARCH.
IF sy-subrc = 0.
x_poitem-po_item = it_ekko_ekpo-ebelp. " PO Item no.
x_poitem-agreement = it_ekko_ekpo-ebeln. " Agreement NO
ENDIF.
x_poitem-short_text = it_head_item-txz01. " Item description
x_poitem-material = it_head_item-matnr. " Material no.
x_poitem-plant = p_werks. " Plant
x_poitem-stge_loc = p_werks. " Storage Loc
x_poitem-matl_group = it_head_item-matkl. " Material group
x_poitem-quantity = it_head_item-menge. " Ordered qty.
x_poitem-po_unit = it_head_item-meins. " Order unit
x_poitem-po_unit_iso = it_head_item-meins. " Order unit
x_poitem-net_price = it_head_item-netpr. " Net price
x_poitem-price_unit = it_head_item-peinh. " price per unit
x_poitem-tax_code = it_head_item-mwskz. " Tax Code
x_poitem-acctasscat = it_head_item-knttp. " Account *** cata
APPEND x_poitem TO it_poitem.
CLEAR x_poitem.
**-Populate PO Item 'X' structure
x_poitemx-po_item = it_ekko_ekpo-ebelp. " PO Item no.
x_poitemx-po_itemx = c_x.
x_poitemx-short_text = c_x.
x_poitemx-material = c_x.
x_poitemx-plant = c_x.
x_poitemx-stge_loc = c_x.
x_poitemx-agreement = c_x.
x_poitemx-matl_group = c_x.
x_poitemx-quantity = c_x.
x_poitemx-po_unit = c_x.
x_poitemx-po_unit_iso = c_x.
x_poitemx-net_price = c_x.
x_poitemx-price_unit = c_x.
x_poitemx-tax_code = c_x.
x_poitemx-acctasscat = c_x.
APPEND x_poitemx TO it_poitemx.
CLEAR x_poitemx.
x_deliveryaddr-po_item = it_ekko_ekpo-ebelp.
x_deliveryaddr-addr_no = it_head_item-adrn2.
APPEND x_deliveryaddr TO it_deliveryaddr.
CLEAR x_deliveryaddr.
AT END OF ebeln.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = x_poheader
poheaderx = x_poheaderx
TABLES
return = it_return
poitem = it_poitem
poitemx = it_poitemx
poaddrdelivery = it_deliveryaddr.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
REFRESH : it_poitemx,it_poitem.
WRITE :/ x_poheader-po_number.
LOOP AT it_return INTO x_return.
WRITE :/ x_return-type,
20 x_return-message.
ENDLOOP.
REFRESH : it_poitemx,it_poitem,it_deliveryaddr,it_return.
CLEAR: x_poheader,x_poheaderx,x_poitem,x_poitemx,x_deliveryaddr.
ENDAT.
ENDLOOP.
ENDFORM. " CREATE_PO
*& Form display_createdpo_rept
text
FORM display_createdpo_rept .
**-Column headings
FORMAT COLOR COL_HEADING.
WRITE:/1(100) sy-uline.
WRITE:/1 sy-vline,
30 'List of PO already created',
100 sy-vline.
FORMAT INTENSIFIED OFF.
FORMAT RESET.
WRITE:/1(100) sy-uline.
*-- Display PO created sucess report
LOOP AT it_sucess.
WRITE:/1 sy-vline,
15 'Purchase Order NO:',
40 it_sucess-ebeln,
100 sy-vline.
ENDLOOP.
WRITE:/1 sy-vline,
2(99) sy-uline,
100 sy-vline.
ENDFORM. " display_createdpo_rept
*& Form display_contract_rept
text
FORM display_contract_rept .
SKIP 3.
**-Column headings
FORMAT COLOR COL_HEADING.
WRITE:/1(100) sy-uline.
WRITE:/1 sy-vline,
30 'List of Contract Numbers',
100 sy-vline.
FORMAT INTENSIFIED OFF.
FORMAT RESET.
WRITE:/1(100) sy-uline.
LOOP AT it_contract.
WRITE:/1 sy-vline,
15 'Purchase Order NO:',
40 it_contract-ebeln,
100 sy-vline.
ENDLOOP.
WRITE:/1 sy-vline,
2(99) sy-uline,
100 sy-vline.
ENDFORM. " display_contract_rept
**& Form RETURN_MESSAGES
text
*FORM return_messages .
*ENDFORM. " RETURN_MESSAGES
*& Form PAGE_HEADING
text
FORM page_heading .
**-List heading
FORMAT COLOR COL_HEADING.
WRITE:/1(100) sy-uline.
WRITE:/1 sy-vline,
40 'Summary Report',
100 sy-vline.
FORMAT INTENSIFIED OFF.
FORMAT RESET.
WRITE:/1(100) sy-uline.
SKIP 5.
ENDFORM. " PAGE_HEADING
Regards -
Using PF_STATUS and USER_COMMAND in ALV
Hi,
I have a requirement to place two buttons on the application toolbar of the output ALV list display screen.
I have to assign functionality for the two buttons.
How do we do it in ALV?
Is there any thing in ALV which performs the functionality of set pf_status and at user_command?Hi Sandeep,
Following code might be useful for you to achieve your goal.
REPORT ZSPRENH062.
TYPE-POOLS : SLIS. "Global Type for ALV
* D A T A *
* Types declarations
*ALV Header table type
TYPES: BEGIN OF TY_HFINAL,
WERKS TYPE EWERK, "Plant
MATKL TYPE MATKL, "Material Group
END OF TY_HFINAL,
*ALV Item table type
BEGIN OF TY_IFINAL,
WERKS TYPE EWERK, "Plant
MATKL TYPE MATKL, "Material Group
SELECT(1) TYPE C, "Check Box
MATNR TYPE MATNR, "Material No
LIFNR TYPE LIFNR, "Vendor Account No.
MAKTX TYPE MAKTX, "Material Desp.
BISMT TYPE BISMT, "Old material ID
CPRICE TYPE KBETR_KOND, "Contract Price
FINCONPRI(20) TYPE C,
INFOREC TYPE KBETR_KOND, "Purchase info rec.
FININFPRI(20) TYPE C,
MPRICE TYPE KBETR_KOND, "Market price
NREPCOST TYPE KBETR_KOND, "Total repl. cost
*----- Begin of Changes EXT-SAP-180 13APR2007 ------*
PRUOM TYPE BSTME, "Purchase Unit of Measure
TRC_BUOM TYPE KBETR_KOND, "Total Repl. Cost in Base UOM
BSUOM TYPE MEINS, "Base Unit of Measure
*----- End of Changes EXT-SAP-180 13APR2007 ------*
PREPCOST TYPE KBETR_KOND, "Previous repl cost
VALCHG TYPE KBETR_KOND, "Total value change
PERCHG TYPE P LENGTH 5 DECIMALS 2, "Percentage Change
END OF TY_IFINAL.
* Internal Table Declarations
*ALV Header Internal Table
DATA: T_HFINAL TYPE STANDARD TABLE OF TY_HFINAL INITIAL SIZE 0,
*ALV Item Internal Table
T_IFINAL TYPE STANDARD TABLE OF TY_IFINAL INITIAL SIZE 0,
T_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV, "Fieldcatalog IT
T_EVENTS TYPE SLIS_T_EVENT, "Event IT
T_HEADER TYPE SLIS_T_LISTHEADER, "Header IT
* Work area Declarations
*ALV Header Work Area
W_HFINAL TYPE TY_HFINAL,
*ALV Item Work Area
W_IFINAL TYPE TY_IFINAL,
W_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV, "Fieldcatalog WA
W_EVENT TYPE SLIS_ALV_EVENT, "Event WA
W_HEADER TYPE SLIS_LISTHEADER, "Header WA
W_LAYOUT TYPE SLIS_LAYOUT_ALV, "Layout WA
W_KEYINFO TYPE SLIS_KEYINFO_ALV, "Key Information WA
* Variable declarations
G_REPID TYPE SY-REPID, "Program Name
G_ANSWER TYPE C, "Optional Button
G_WERKS TYPE EWERK,
G_MATKL TYPE MATKL,
G_MATNR TYPE MATNR,
G_MTART TYPE MTART,
G_LIFNR TYPE ELIFN,
L_CPRICE_C(20) TYPE C,
L_CPRICE_I(20) TYPE C,
L_UNITPRICE_C(20) TYPE C,
L_UNITPRICE_I(20) TYPE C.
* Constant declarations
CONSTANTS: C_A(1) TYPE C VALUE 'A', "Constant Value A
C_E(1) TYPE C VALUE 'E', "Constant Value E
C_H(1) TYPE C VALUE 'H', "Constant Value H
C_M(1) TYPE C VALUE 'M', "Constant Value M
C_S(1) TYPE C VALUE 'S', "Constant Value S
C_X(1) TYPE C VALUE 'X', "Constant Value X
C_0(1) TYPE C VALUE '0', "Constant Value 0
C_R(1) TYPE C VALUE 'R', "Constant Value R
C_2(1) TYPE C VALUE '2', "Constant Value 2
C_LANG(2) TYPE C VALUE 'EN', "Language English
C_ZQTE(4) TYPE C VALUE 'ZQTE', "Condtion type ZQTE
C_HTNAME(10) TYPE C VALUE 'T_HFINAL', "Header table name
C_ITNAME(10) TYPE C VALUE 'T_IFINAL'. "Item table name
* S E L E C T O P T I O N S & P A R A M E T E R S *
* Selection-screen Block 1
SELECTION-SCREEN BEGIN OF BLOCK BLK1
WITH FRAME TITLE TEXT-001. "Begin of Block1
PARAMETERS : P_EKORG TYPE EKORG OBLIGATORY. "Pur.Organization
SELECT-OPTIONS : S_WERKS FOR G_WERKS OBLIGATORY, "Plant
S_MATKL FOR G_MATKL, "Material Group
S_MATNR FOR G_MATNR, "Material No.
S_MTART FOR G_MTART, "Material Type
S_LIFNR FOR G_LIFNR. "Vendor
PARAMETERS : P_PERCHG(3) TYPE C. "Percentage Change
SELECTION-SCREEN END OF BLOCK BLK1. "End of Block 1
* Selection-screen Block 2
SELECTION-SCREEN BEGIN OF BLOCK BLK2
WITH FRAME TITLE TEXT-002. "Begin of Block2
PARAMETERS: P_VDATE TYPE DATAM DEFAULT SY-DATUM, "Valid on date
P_HDATE TYPE DATAM DEFAULT '29991231'."Horizon date
SELECTION-SCREEN END OF BLOCK BLK2. "End of Block 2
* I N I T I A L I Z A T I O N *
INITIALIZATION.
CLEAR : G_REPID. "Program Name
G_REPID = SY-REPID. "Program Name
* A T S E L E C T I O N S C R E E N *
AT SELECTION-SCREEN.
* Validation for Change of Percentage
IF P_PERCHG LT 0 OR P_PERCHG GT 100.
MESSAGE E000(ZS) WITH TEXT-E01.
ENDIF.
* Validation for Horizon Date
IF P_HDATE LE P_VDATE.
MESSAGE E000(ZS) WITH TEXT-E02.
ENDIF.
* S T A R T O F S E L E C T I O N *
START-OF-SELECTION.
* Data Selection
PERFORM DATA_RETRIEVAL.
* Build Field Catalog
PERFORM BUILD_FIELDCATALOG.
* Bulid layout
PERFORM BUILD_LAYOUT.
* Build Events
PERFORM BUILD_EVENTS.
* E N D O F S E L E C T I O N *
END-OF-SELECTION.
* Build Header for Top-Of-Page
PERFORM BUILD_TOPOFPAGE.
* Display List
PERFORM DISPLAY_ALV_REPORT.
* F O R M S *
*& Form data_retrieval
* To fetch data from Database table into ALV final Internal table
FORM DATA_RETRIEVAL.
* Local Types declarations
*Types of EORD & EKPO table
TYPES : BEGIN OF TY_MAIN,
MATNR TYPE MATNR, "Material No.
WERKS TYPE EWERK, "Plant
ZEORD TYPE DZEORD, "No.Source List Rec
LIFNR TYPE ELIFN, "Vendor Account No.
EBELN TYPE EVRTN, "Agreement Number
EBELP TYPE EVRTP, "Agreement Item
EKORG TYPE EKORG, "Pur. Organization
AUTET TYPE AUTET, "S.L. in Mat.Planning
MATKL TYPE MATKL, "Material Group
MTART TYPE MTART, "Material Type
INFNR TYPE INFNR, "No.Pur.Info Record
* Begin of Changes CON-SAP-99 16/01/2007 *
NETPR TYPE BPREI, "Net Price
* End of Changes CON-SAP-99 16/01/2007 *
*----- Begin of Changes EXT-SAP-180 13APR2007 ------ *
MEINS TYPE BSTME, "Purchase Order Unit of Measure
*----- End of Changes EXT-SAP-180 13APR2007 ------ *
* begin 23APR2007 ------
PEINH TYPE EPEIN, "Price Unit
* end 23APR2007 ------
PSTYP TYPE PSTYP, "Item Category
KONNR TYPE KONNR, "No.Principal P.A.
KTPNR TYPE KTPNR, "Item No.Principal P.A.
END OF TY_MAIN,
*Types of MARA table
BEGIN OF TY_MARA,
MATNR TYPE MATNR, "Material No.
MEINS TYPE MEINS, "Base Unit of Measure " ext-sap-180 13APR2007
END OF TY_MARA,
*Types of MAKT table
BEGIN OF TY_MAKT,
MATNR TYPE MATNR, "Material No.
MAKTX TYPE MAKTX, "Material Desp.
END OF TY_MAKT,
*Types of MBEW table
BEGIN OF TY_MBEW,
MATNR TYPE MATNR, "Material No.
BWKEY TYPE BWKEY, "Valuation Area
*----- Begin of Changes EXT-SAP-180 13APR2007 ------ *
PEINH TYPE PEINH, "Price Unit
*----- End of Changes EXT-SAP-180 13APR2007 ------ *
ZPLP3 TYPE DZPLP3, "Future Planned Price
END OF TY_MBEW,
*Types of A016_C table
BEGIN OF TY_A016_C,
EVRTN TYPE EBELN, "Purchasing Doc. No.
EVRTP TYPE EBELP, "Item No.of Pur. Doc.
KNUMH TYPE KNUMH, "Condition rec.no.
END OF TY_A016_C,
*Types of A017_P table
BEGIN OF TY_A017_P,
LIFNR TYPE ELIFN, "Vendor Account No.
MATNR TYPE MATNR, "Material No.
EKORG TYPE EKORG, "Pur. Organization
WERKS TYPE WERKS_D, "Plant
KNUMH TYPE KNUMH, "Condition rec.no.
END OF TY_A017_P,
*Types of A054_M table
BEGIN OF TY_A054_M,
KSCHL TYPE KSCHA, "Condition type
EKORG TYPE EKORG, "Pur. Organization
MATKL TYPE MATKL, "Material Group
* Begin of Changes EXT-SAP-180 02APR2007 *
MATNR TYPE MATNR, "Material Number
DATBI TYPE KODATBI, " Validity end date of the condition record 04APR07
DATAB TYPE KODATAB, " Validity start date of the condition record 04APR0
* End of Changes EXT-SAP-180 02APR2007 *
KNUMH TYPE KNUMH, "Condition rec.no.
END OF TY_A054_M,
*Types of KONP_P table
BEGIN OF TY_KONP_P,
KNUMH TYPE KNUMH, "Condition rec.no.
KBETR TYPE KBETR_KOND, "Rate
KONWA TYPE KONWA, "Rate unit
KPEIN TYPE KPEIN, "Condition pricing unit
KMEIN TYPE KMEIN, "Condition Unit
END OF TY_KONP_P,
* Begin of Changes EXT-SAP-180 02APR2007 *
* Types of A049 table
BEGIN OF TY_A049,
KSCHL TYPE KSCHA, " Condition Type
EKORG TYPE EKORG, " Purchasing Organization
MATKL TYPE MATKL, " Material Group
MATNR TYPE MATNR, " Material Number
DATBI TYPE KODATBI, " Validity end date of the condition record 04APR07
DATAB TYPE KODATAB, " Validity start date of the condition record 04APR07
KNUMH TYPE KNUMH, " Condition Record Number
END OF TY_A049,
* Types of KONP_C table
BEGIN OF TY_KONP_C,
KNUMH TYPE KNUMH, "Condition rec.no.
KOPOS TYPE KOPOS,
KSCHL TYPE KSCHA, "Condition type
KBETR TYPE KBETR_KOND, "Rate
KONWA TYPE KONWA, "Rate unit
END OF TY_KONP_C,
*Types of KONM_C table
BEGIN OF TY_KONM_C,
KNUMH TYPE KNUMH, "Condition rec.no.
KOPOS TYPE KOPOS, "Seq. no. of the condition
KSTBM TYPE KSTBM, "Condition scale quan.
KBETR TYPE KBETR, "Rate
END OF TY_KONM_C,
*Types of KONM_P table
BEGIN OF TY_KONM_P,
KNUMH TYPE KNUMH, "Condition rec.no.
KSTBM TYPE KSTBM, "Condition scale quan.
KBETR TYPE KBETR, "Rate
END OF TY_KONM_P,
* End of Changes EXT-SAP-180 02APR2007 *
*----- Begin of Changes EXT-SAP-180 13APR2007 ------*
*Types of EINE table
BEGIN OF TY_EINE,
INFNR TYPE INFNR, " Number of Purchase Info Record
EKORG TYPE EKORG, " Purchasing Organization
WERKS TYPE EWERK, " Plant
PEINH TYPE EPEIN, " Price Unit
BPRME TYPE BBPRM, " Order Price Unit (Purchasing)
END OF TY_EINE,
*Types of MARM table
BEGIN OF TY_MARM,
MATNR TYPE MATNR, " Material Number
MEINH TYPE LRMEI, " Alternative Unit of Measure
UMREZ TYPE UMREZ, " Numerator for Conversion to Base UOM
UMREN TYPE UMREN, " Denominator for Conversion to Base UOM
END OF TY_MARM,
*----- End of Changes EXT-SAP-180 13APR2007 ------*
*Types of EKAB table
BEGIN OF TY_EKAB,
KONNR TYPE KONNR, "No of Principal P.A
KTPNR TYPE KTPNR, "Item of Principal P.A
EBELN TYPE EBELN, "Purchasing Doc. No.
MENGE TYPE BSTMG, "P.O. Quantity
END OF TY_EKAB,
*Types of EKPO table
BEGIN OF TY_EKPO,
INFNR TYPE INFNR, "No of Pur.Info Rec.
EBELN TYPE EBELN, "Purchasing Doc. No.
MENGE TYPE MENGE_D, "P.O. Quantity
END OF TY_EKPO.
* Local Internal table declarations
DATA: T_MAIN TYPE STANDARD TABLE OF TY_MAIN,
T_MAIN1 TYPE STANDARD TABLE OF TY_MAIN,
T_MARA TYPE STANDARD TABLE OF TY_MARA,
T_MBEW TYPE STANDARD TABLE OF TY_MBEW,
T_MAKT TYPE STANDARD TABLE OF TY_MAKT,
T_A016_C TYPE STANDARD TABLE OF TY_A016_C,
T_A017_P TYPE STANDARD TABLE OF TY_A017_P,
T_A054_M TYPE STANDARD TABLE OF TY_A054_M,
* Begin of Changes EXT-SAP-180 02APR2007 *
T_KONP_C TYPE STANDARD TABLE OF TY_KONP_C,
T_A049 TYPE STANDARD TABLE OF TY_A049,
* End of Changes EXT-SAP-180 02APR2007 *
*----- Begin of Changes EXT-SAP-180 13APR2007 ------*
T_EINE TYPE STANDARD TABLE OF TY_EINE,
T_MARM TYPE STANDARD TABLE OF TY_MARM,
*----- End of Changes EXT-SAP-180 13APR2007 ------*
T_KONP_P TYPE STANDARD TABLE OF TY_KONP_P,
T_KONP_M TYPE STANDARD TABLE OF TY_KONP_P,
* Begin of Changes EXT-SAP-180 02APR2007 *
T_KONM_C TYPE STANDARD TABLE OF TY_KONM_C,
T_KONM_P TYPE STANDARD TABLE OF TY_KONM_P,
* End of Changes EXT-SAP-180 02APR2007 *
T_EKAB TYPE STANDARD TABLE OF TY_EKAB,
T_EKPO TYPE STANDARD TABLE OF TY_EKPO,
* Local Work Area declarations
W_MAIN TYPE TY_MAIN,
W_MARA TYPE TY_MARA,
W_MBEW TYPE TY_MBEW,
W_A016_C TYPE TY_A016_C,
W_A017_P TYPE TY_A017_P,
W_A054_M TYPE TY_A054_M,
* Begin of Changes EXT-SAP-180 02APR2007 *
W_KONP_C TYPE TY_KONP_C,
W_MAIN1_T TYPE TY_MAIN,
W_A049_T TYPE TY_A049,
* End of Changes EXT-SAP-180 02APR2007 *
*----- Begin of Changes EXT-SAP-180 13APR2007 ------*
W_EINE TYPE TY_EINE,
W_MARM TYPE TY_MARM,
*----- End of Changes EXT-SAP-180 13APR2007 ------*
W_KONP_P TYPE TY_KONP_P,
W_KONP_M TYPE TY_KONP_P,
* Begin of Changes EXT-SAP-180 02APR2007 *
W_KONM_C TYPE TY_KONM_C,
W_KONM_P TYPE TY_KONM_P,
W_KONM1 TYPE TY_KONM_C,
W_KONM2 TYPE TY_KONM_P,
* End of Changes EXT-SAP-180 02APR2007 *
W_EKAB TYPE TY_EKAB,
W_EKPO TYPE TY_EKPO,
W_MAKT TYPE TY_MAKT,
* Local Variable declarations
L_PERPRICE TYPE KBETR_KOND, "Local Percentage price
L_PERUNIT TYPE KPEIN, "Condition Pricing Unit
L_MARPRICE TYPE KBETR_KOND, "Local Market price
* Begin of Changes EXT-SAP-180 02APR2007 *
L_KBETR TYPE KBETR,
L_INDEX TYPE SY-TABIX, "Tab Index
* End of Changes EXT-SAP-180 02APR2007 *
* Begin of Changes CON-SAP-99 11/12/2006 *
L_STR TYPE STRING.
* End of Changes CON-SAP-99 11/12/2006 *
* GET SOURCE LIST
SELECT A~MATNR "Material No.
A~WERKS "Plant
A~ZEORD "No.Source List Rec
A~LIFNR "Vendor Account No.
A~EBELN "Agreement Number
A~EBELP "Agreement Item
A~EKORG "Pur. Organization
A~AUTET "S.L. in Mat.Planning
B~MATKL "Material Group
B~MTART "Material Type
B~INFNR "No.Pur.Info Record
* Begin of Changes CON-SAP-99 16/01/2007 *
B~NETPR "Net price
* End of Changes CON-SAP-99 16/01/2007 *
*----- Begin of Changes EXT-SAP-180 13APR2007 ------ *
B~MEINS "Purchase Order Unit of Measure
*----- End of Changes EXT-SAP-180 13APR2007 ------ *
* begin 23APR2007 ------
B~PEINH "Price Unit
* end 23APR2007 ------
B~PSTYP "Pur. Doc. Category
B~KONNR "No.Principal P.A.
B~KTPNR "Item No.Principal P.A.
INTO TABLE T_MAIN
FROM EORD AS A INNER JOIN EKPO AS B
ON ( A~EBELN EQ B~EBELN
AND A~EBELP EQ B~EBELP )
WHERE A~MATNR IN S_MATNR
AND A~LIFNR IN S_LIFNR
AND A~WERKS IN S_WERKS
AND B~MATKL IN S_MATKL
AND B~MTART IN S_MTART
AND A~EKORG EQ P_EKORG
AND A~VDATU LE P_VDATE
AND A~BDATU GE P_VDATE
AND ( A~AUTET EQ 1
OR A~AUTET EQ 2 ).
IF SY-SUBRC = 0.
SORT T_MAIN BY MATNR WERKS.
DELETE ADJACENT DUPLICATES FROM T_MAIN
COMPARING MATNR
WERKS.
T_MAIN1[] = T_MAIN[].
DELETE ADJACENT DUPLICATES FROM T_MAIN1
COMPARING MATNR.
* GET MATERIAL DESCRIPTION
SELECT MATNR "Material No
MAKTX "Material Desp.
FROM MAKT
INTO TABLE T_MAKT
FOR ALL ENTRIES IN T_MAIN1
WHERE MATNR EQ T_MAIN1-MATNR
AND SPRAS EQ C_LANG.
IF SY-SUBRC = 0.
SORT T_MAKT BY MATNR.
ENDIF.
*----- Begin of Changes EXT-SAP-180 13APR2007 ------ *
* GET PURCHASE ORDER UNIT OF MEASURE FOR INFO RECORDS FROM EINE
SELECT INFNR " Number of Purchase Info Record
EKORG " Purchasing Organization
WERKS " Plant
PEINH " Price Unit
BPRME " Order Price Unit
FROM EINE
INTO TABLE T_EINE
FOR ALL ENTRIES IN T_MAIN1
WHERE INFNR EQ T_MAIN1-INFNR
AND EKORG EQ T_MAIN1-EKORG
AND ( ESOKZ EQ C_0 OR ESOKZ EQ C_2 ) "Purchasing Info Record Category = Standard
AND WERKS EQ T_MAIN1-WERKS.
IF SY-SUBRC = 0.
SORT T_EINE BY INFNR EKORG WERKS.
ENDIF.
SELECT MATNR " Material Number
MEINH " Alternate UOM
UMREZ " Numerator for conversion
UMREN " Denominator for conversion
FROM MARM
INTO TABLE T_MARM
FOR ALL ENTRIES IN T_MAIN1
WHERE MATNR EQ T_MAIN1-MATNR.
IF SY-SUBRC = 0.
SORT T_MARM BY MATNR MEINH.
ENDIF.
*----- End of Changes EXT-SAP-180 13APR2007 ------ *
* GET BASE UNIT OF MEASURE
SELECT MATNR "Material No.
MEINS "Base unit of measure " ext-sap-180 13APR2007
INTO TABLE T_MARA
FROM MARA
FOR ALL ENTRIES IN T_MAIN1
WHERE MATNR EQ T_MAIN1-MATNR.
IF SY-SUBRC = 0.
SORT T_MARA BY MATNR.
ENDIF.
* GET CONTRACT PRICE
REFRESH T_MAIN1[].
T_MAIN1[] = T_MAIN[].
SORT T_MAIN1 BY PSTYP.
DELETE T_MAIN1 WHERE PSTYP = 2.
IF T_MAIN1 IS NOT INITIAL.
SORT T_MAIN1 BY EBELN EBELP.
* Get Condition Record Number based on Purchasing Document Number
SELECT EVRTN "Purchasing Doc. No.
EVRTP "Item No.of Pur. Doc.
KNUMH "Condition rec.no.
FROM A016
INTO TABLE T_A016_C
FOR ALL ENTRIES IN T_MAIN1
WHERE KAPPL EQ C_M
AND EVRTN EQ T_MAIN1-EBELN
AND EVRTP EQ T_MAIN1-EBELP
AND DATBI GE P_VDATE
AND DATAB LE P_VDATE.
IF SY-SUBRC = 0.
SORT T_A016_C BY EVRTN EVRTP.
ENDIF.
SORT T_MAIN1 BY KONNR KTPNR.
*Get Condition Record No. based on Principal Purchasing Document No
SELECT EVRTN "Purchasing Doc. No.
EVRTP "Item No.of Pur. Doc.
KNUMH "Condition rec.no.
FROM A016
APPENDING TABLE T_A016_C
FOR ALL ENTRIES IN T_MAIN1
WHERE KAPPL EQ C_M
AND EVRTN EQ T_MAIN1-KONNR
AND EVRTP EQ T_MAIN1-KTPNR
AND DATBI GE P_VDATE
AND DATAB LE P_VDATE.
IF T_A016_C IS NOT INITIAL.
SORT T_A016_C BY EVRTN EVRTP.
*Get Rate & unit for all the Condition Record No.(Contract Price)
SELECT KNUMH "Condition rec.no.
* Begin of Changes EXT-SAP-180 02APR2007 *
KOPOS "Seq. No. of the condition
KSCHL "Condition Type
* End of Changes EXT-SAP-180 02APR2007 *
KBETR "Rate
KONWA "Rate unit
FROM KONP
INTO TABLE T_KONP_C
FOR ALL ENTRIES IN T_A016_C
WHERE KNUMH EQ T_A016_C-KNUMH
* Begin of Changes EXT-SAP-180 02APR2007 *
AND LOEVM_KO EQ SPACE.
* End of Changes EXT-SAP-180 02APR2007 *
IF SY-SUBRC = 0.
SORT T_KONP_C BY KNUMH.
ENDIF.
* Get Condition scale quantity & Rate for all the Condition Record No.
SELECT KNUMH "Condition rec.no.
* Begin of Changes EXT-SAP-180 02APR2007 *
KOPOS "Seq. No. of the condition
* End of Changes EXT-SAP-180 02APR2007 *
KSTBM "Condition scale quan.
KBETR "Rate
FROM KONM
INTO TABLE T_KONM_C
FOR ALL ENTRIES IN T_A016_C
WHERE KNUMH EQ T_A016_C-KNUMH.
IF SY-SUBRC = 0.
SORT T_KONM_C BY KNUMH
* Begin of Changes EXT-SAP-180 02APR2007 *
KOPOS
* End of Changes EXT-SAP-180 02APR2007 *
KSTBM
DESCENDING.
ENDIF.
* Get PO Doc. No. & Quantity based on Principal Purchasing Doc. No
SELECT KONNR "No of Principal P.A
KTPNR "Item of Principal P.A
EBELN "Purchasing Doc. No.
MENGE "P.O. Quantity
FROM EKAB
INTO TABLE T_EKAB
FOR ALL ENTRIES IN T_A016_C
WHERE KONNR EQ T_A016_C-EVRTN
AND KTPNR EQ T_A016_C-EVRTP.
IF SY-SUBRC = 0.
SORT T_EKAB BY KONNR KTPNR EBELN DESCENDING.
ENDIF.
ENDIF.
ENDIF.
* GET PURCHASING INFO RECORDS PRICE
REFRESH T_MAIN1[].
T_MAIN1[] = T_MAIN[].
DELETE T_MAIN1 WHERE PSTYP <> 2.
IF T_MAIN1 IS NOT INITIAL.
SORT T_MAIN1 BY LIFNR MATNR EKORG WERKS.
* Get Condition Record No based on Vendor,Material,Pur.org & Plant
SELECT LIFNR "Vendor Account No.
MATNR "Material No.
EKORG "Pur. Organization
WERKS "Plant
KNUMH "Condition rec.no.
FROM A017
INTO TABLE T_A017_P
FOR ALL ENTRIES IN T_MAIN1
WHERE LIFNR EQ T_MAIN1-LIFNR
AND MATNR EQ T_MAIN1-MATNR
AND EKORG EQ T_MAIN1-EKORG
AND WERKS EQ T_MAIN1-WERKS
AND DATBI GE P_VDATE
AND DATAB LE P_VDATE.
IF SY-SUBRC = 0.
SORT T_A017_P BY LIFNR MATNR EKORG WERKS.
*Get Rate & unit for all the Condition Rec.No.(Pur. info Rec Price)
SELECT KNUMH "Condition rec.no.
KBETR "Rate
KONWA "Rate unit
KPEIN "Condition pricing unit
KMEIN "Condition Unit
FROM KONP
INTO TABLE T_KONP_P
FOR ALL ENTRIES IN T_A017_P
WHERE KNUMH EQ T_A017_P-KNUMH.
IF SY-SUBRC = 0.
SORT T_KONP_P BY KNUMH.
ENDIF.
* Get Condition scale quantity & Rate for all the Condition Record No.
SELECT KNUMH "Condition rec.no.
KSTBM "Condition scale quan.
KBETR "Rate
FROM KONM
INTO TABLE T_KONM_P
FOR ALL ENTRIES IN T_A017_P
WHERE KNUMH EQ T_A017_P-KNUMH.
IF SY-SUBRC = 0.
SORT T_KONM_P BY KNUMH KSTBM DESCENDING.
ENDIF.
ENDIF.
* Get PO Doc. No. & Quantity based on Principal Purchasing Doc. No
SORT T_MAIN1 BY INFNR.
SELECT INFNR "No of Pur.Info Rec.
EBELN "Purchasing Doc. No.
MENGE "P.O. Quantity
FROM EKPO
INTO TABLE T_EKPO
FOR ALL ENTRIES IN T_MAIN1
WHERE INFNR EQ T_MAIN1-INFNR
AND WERKS EQ T_MAIN1-WERKS
AND BSTYP EQ 'F'.
IF SY-SUBRC = 0.
SORT T_EKPO BY INFNR EBELN DESCENDING.
ENDIF.
ENDIF.
* GET MARKET PRICE
REFRESH T_MAIN1[].
T_MAIN1[] = T_MAIN[].
DELETE ADJACENT DUPLICATES FROM T_MAIN1 COMPARING EKORG MATKL.
P_VDATE = P_VDATE + 1.
* Begin of Changes EXT-SAP-180 02APR2007 *
* Get Condition Record No based on Material Number
SELECT KSCHL
EKORG
MATNR
DATBI "EXT-SAP-180 04Apr07
DATAB "EXT-SAP-180 04Apr07
KNUMH
FROM A049
INTO CORRESPONDING FIELDS OF TABLE T_A049
FOR ALL ENTRIES IN T_MAIN
WHERE KSCHL EQ C_ZQTE
AND EKORG EQ T_MAIN-EKORG
AND MATNR EQ T_MAIN-MATNR
AND ESOKZ EQ C_0.
IF SY-SUBRC EQ 0. " if entries exists in t_a049
SORT T_A049 BY EKORG MATNR
DATBI DATAB. " EXT-SAP-180 04Apr07
CLEAR L_INDEX.
LOOP AT T_A049 INTO W_A049_T.
L_INDEX = SY-TABIX.
READ TABLE T_MAIN INTO W_MAIN1_T
WITH KEY EKORG = W_A049_T-EKORG
MATNR = W_A049_T-MATNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_A049_T-MATKL = W_MAIN1_T-MATKL.
MODIFY T_A049 FROM W_A049_T
INDEX L_INDEX
TRANSPORTING MATKL.
ENDIF.
CLEAR: W_A049_T,
W_MAIN1_T,
L_INDEX.
ENDLOOP.
* Get Rate & unit for all the Condition Record No. (Market price)
SELECT KNUMH "Condition rec.no.
KBETR "Rate
KONWA "Rate unit
KPEIN "Condition Pricing Unit
KMEIN "Condition Unit
FROM KONP
INTO TABLE T_KONP_M
FOR ALL ENTRIES IN T_A049
WHERE KNUMH EQ T_A049-KNUMH.
IF SY-SUBRC = 0.
SORT T_KONP_C BY KNUMH.
ENDIF.
ENDIF.
* End of Changes EXT-SAP-180 02APR2007 *
*Get Condition Record No based on Condition type, Pur.Org.,Mat. group
SELECT KSCHL "Condition type
EKORG "Pur. Organization
MATKL "Material Group
DATBI "Valid to date EXT-SAP-180 04Apr07
DATAB "Valid from date EXT-SAP-180 04Apr07
KNUMH "Condition rec.no.
FROM A054
INTO CORRESPONDING FIELDS OF TABLE T_A054_M
FOR ALL ENTRIES IN T_MAIN
WHERE KSCHL EQ C_ZQTE
AND EKORG EQ T_MAIN-EKORG
AND MATKL EQ T_MAIN-MATKL
AND ESOKZ EQ C_0.
IF SY-SUBRC = 0.
SORT T_A054_M BY EKORG MATKL
DATBI DATAB. " added by SAP-EXT-180 04Apr07
* Get Rate & unit for all the Condition Record No. (Market price)
SELECT KNUMH "Condition rec.no.
KBETR "Rate
KONWA "Rate unit
KPEIN "Condition Pricing Unit
KMEIN "Condition Unit
FROM KONP
APPENDING TABLE T_KONP_M
FOR ALL ENTRIES IN T_A054_M
WHERE KNUMH EQ T_A054_M-KNUMH.
IF SY-SUBRC = 0.
SORT T_KONP_C BY KNUMH KOPOS KSCHL.
* Begin of Changes EXT-SAP-180 02APR2007 *
SORT T_KONP_M BY KNUMH.
* End of Changes EXT-SAP-180 02APR2007 *
ENDIF.
ENDIF.
* GET PREVIOUS REPLACEMENT COST
SELECT MATNR "Material No.
BWKEY "Valuation Area
*----- Begin of Changes EXT-SAP-180 13APR2007 ------ *
PEINH "Price Unit
*----- End of Changes EXT-SAP-180 13APR2007 ------ *
ZPLP3 "Future Planned Price
FROM MBEW
INTO TABLE T_MBEW
FOR ALL ENTRIES IN T_MAIN
WHERE MATNR EQ T_MAIN-MATNR
AND BWKEY EQ T_MAIN-WERKS.
IF SY-SUBRC = 0.
SORT T_MBEW BY MATNR BWKEY.
ENDIF.
* TRANSFERING DATA INTO FINAL INTERNAL TABLE
CLEAR : W_MAIN.
LOOP AT T_MAIN INTO W_MAIN.
* Clear the Work area
CLEAR : W_MAKT,
W_MARA,
W_MBEW,
W_A016_C,
W_A017_P,
W_A054_M,
W_KONP_C,
W_KONP_P,
W_KONP_M,
W_KONM_C,
W_KONM_P,
W_KONM1,
* Begin of Changes EXT-SAP-180 02APR2007 *
W_KONM2,
W_A049_T,
* End of Changes EXT-SAP-180 02APR2007 *
W_EKAB,
W_EKPO.
CLEAR : W_HFINAL,
W_IFINAL.
* PLANT, MATERIAL GROUP
W_HFINAL-WERKS = W_MAIN-WERKS. "Plant(H)
W_HFINAL-MATKL = W_MAIN-MATKL. "Material Group(H)
W_IFINAL-WERKS = W_MAIN-WERKS. "Plant(I)
W_IFINAL-MATKL = W_MAIN-MATKL. "Material Group(I)
* MATERIAL NUMBER, VENDER NUMBER
W_IFINAL-MATNR = W_MAIN-MATNR. "Material No.
W_IFINAL-LIFNR = W_MAIN-LIFNR. "Vendor
* MATERIAL DESCRIPTION
READ TABLE T_MAKT INTO W_MAKT
WITH KEY MATNR = W_MAIN-MATNR
BINARY SEARCH.
IF SY-SUBRC = 0.
W_IFINAL-MAKTX = W_MAKT-MAKTX. "Material Desp.
ENDIF.
* BASE UNIT OF MEASURE
READ TABLE T_MARA INTO W_MARA
WITH KEY MATNR = W_MAIN-MATNR
BINARY SEARCH.
IF SY-SUBRC = 0.
*----- Begin of Changes EXT-SAP-180 13APR2007 ------*
W_IFINAL-BSUOM = W_MARA-MEINS.
*----- End of Changes EXT-SAP-180 13APR2007 ------*
ENDIF.
* CONTRACT PRICE
IF W_MAIN-PSTYP <> 2.
* Assigning Scheduling agreement reference no. into agreement no.
IF W_MAIN-AUTET EQ 2.
W_MAIN-EBELN = W_MAIN-KONNR.
W_MAIN-EBELP = W_MAIN-KTPNR.
ENDIF.
*----- Begin of Changes EXT-SAP-180 13APR2007 ------*
* Assigning Purchase Order Unit of Measure
W_IFINAL-PRUOM = W_MAIN-MEINS.
*----- Begin of Changes EXT-SAP-180 13APR2007 ------*
* Read conditon no. for agreement no.
READ TABLE T_A016_C INTO W_A016_C
WITH KEY EVRTN = W_MAIN-EBELN
EVRTP = W_MAIN-EBELP
BINARY SEARCH.
IF SY-SUBRC = 0.
* Begin of insertion EXT-SAP-180 02APR2007 *
LOOP AT T_KONP_C INTO W_KONP_C
WHERE KNUMH = W_A016_C-KNUMH.
* End of insertion EXT-SAP-180 02APR2007 *
* to check scales
READ TABLE T_KONM_C INTO W_KONM_C
WITH KEY KNUMH = W_A016_C-KNUMH
* Begin of Changes EXT-SAP-180 02APR2007 *
KOPOS = W_KONP_C-KOPOS
* End of Changes EXT-SAP-180 02APR2007 *
BINARY SEARCH.
IF SY-SUBRC = 0.
* Check Purchase order for Contract Price with scales
READ TABLE T_EKAB INTO W_EKAB
WITH KEY KONNR = W_A016_C-EVRTN
KTPNR = W_A016_C-EVRTP
BINARY SEARCH.
IF SY-SUBRC = 0.
SORT T_KONM_C BY KNUMH KSTBM.
* Get the Contract price, if Purchase order exist
LOOP AT T_KONM_C INTO W_KONM1
WHERE KNUMH EQ W_A016_C-KNUMH
AND KSTBM LE W_EKAB-MENGE.
CLEAR L_KBETR.
IF SY-SUBRC = 0.
L_KBETR = W_KONM1-KBETR.
CONTINUE.
ENDIF.
ENDLOOP.
* the above looping is done to get the right scale & stop, then add
* the scale amount to the existing contract price in the below step.
W_IFINAL-CPRICE = W_IFINAL-CPRICE + L_KBETR.
CLEAR : W_KONM1,
L_KBETR.
* Begin of Changes EXT-SAP-180 02APR2007 *
SORT T_KONM_C BY KNUMH
KOPOS
KSTBM
DESCENDING.
* End of Changes EXT-SAP-180 02APR2007 *
ELSE.
* Get the Contract price, if doesnot Purchase order exist
W_IFINAL-CPRICE = W_IFINAL-CPRICE + W_KONM_C-KBETR. "Changed EXT-SAP-180 02APR2007
ENDIF.
CLEAR W_EKAB.
ELSE.
* Contract Price with out scales
* Begin of Changes EXT-SAP-180 02APR2007 *
READ TABLE T_KONP_C INTO W_KONP_C
WITH KEY KNUMH = W_A016_C-KNUMH
KSCHL = W_KONP_C-KSCHL
BINARY SEARCH.
IF SY-SUBRC = 0.
W_IFINAL-CPRICE = W_IFINAL-CPRICE + W_KONP_C-KBETR.
ENDIF.
CLEAR W_KONP_C.
* End of Changes EXT-SAP-180 02APR2007 *
ENDIF.
CLEAR W_KONM_C.
* Begin of Changes EXT-SAP-180 02APR2007 *
ENDLOOP.
* End of Changes EXT-SAP-180 02APR2007 *
*----BEGIN OF CHANGE EXT-SAP-180 23rd April 2007
L_CPRICE_C = W_IFINAL-CPRICE.
CONDENSE L_CPRICE_C. "NO-GAPS.
IF W_MAIN-PEINH IS INITIAL.
W_IFINAL-FINCONPRI = L_CPRICE_C.
ELSE.
L_UNITPRICE_C = W_MAIN-PEINH.
CONDENSE L_UNITPRICE_C. " NO-GAPS.
CONCATENATE L_CPRICE_C '/' L_UNITPRICE_C W_MAIN-MEINS INTO W_IFINAL-FINCONPRI.
ENDIF.
CLEAR: L_CPRICE_C,
L_UNITPRICE_C.
*----END OF CHANGE EXT-SAP-180 23rd April 2007
ENDIF.
CLEAR W_A016_C.
ENDIF.
* PURCHASE INFO RECORD
IF W_MAIN-PSTYP = 2.
*----- Begin of Changes EXT-SAP-180 13APR2007 ------*
READ TABLE T_EINE INTO W_EINE
WITH KEY INFNR = W_MAIN-INFNR
EKORG = W_MAIN-EKORG
WERKS = W_MAIN-WERKS
BINARY SEARCH.
IF SY-SUBRC = 0.
W_IFINAL-PRUOM = W_EINE-BPRME.
ENDIF.
*----- End of Changes EXT-SAP-180 13APR2007 ------*
READ TABLE T_A017_P INTO W_A017_P
WITH KEY LIFNR = W_MAIN-LIFNR
MATNR = W_MAIN-MATNR
EKORG = W_MAIN-EKORG
WERKS = W_MAIN-WERKS
BINARY SEARCH.
IF SY-SUBRC = 0.
* To check scales
READ TABLE T_KONM_P INTO W_KONM_P
WITH KEY KNUMH = W_A017_P-KNUMH
BINARY SEARCH.
IF SY-SUBRC = 0.
* Check Purchase order for Purchase info record Price with scales
READ TABLE T_EKPO INTO W_EKPO
WITH KEY INFNR = W_MAIN-INFNR
BINARY SEARCH.
IF SY-SUBRC = 0.
SORT T_KONM_P BY KNUMH KSTBM.
* Get the Pur.info rec. , if Purchase order exist
LOOP AT T_KONM_P INTO W_KONM2
WHERE KNUMH EQ W_A017_P-KNUMH
AND KSTBM LE W_EKPO-MENGE.
W_IFINAL-INFOREC = W_KONM2-KBETR. "Pur.Info rec.
ENDLOOP.
ELSE.
* Get the Pur.info rec. price, if doesnot Purchase order exist
W_IFINAL-INFOREC = W_KONM_P-KBETR. "Pur.Info rec.
ENDIF.
ELSE.
* Get Pur.info rec. price,with out scales
READ TABLE T_KONP_P INTO W_KONP_P
WITH KEY KNUMH = W_A017_P-KNUMH
BINARY SEARCH.
IF SY-SUBRC = 0.
W_IFINAL-INFOREC = W_KONP_P-KBETR. "Pur.Info rec.
ENDIF.
ENDIF.
ENDIF.
*----BEGIN OF CHANGE EXT-SAP-180 23rd April 2007
L_CPRICE_I = W_IFINAL-INFOREC.
CONDENSE L_CPRICE_I.
IF W_EINE-PEINH IS INITIAL.
W_IFINAL-FININFPRI = L_CPRICE_I.
ELSE.
L_UNITPRICE_I = W_EINE-PEINH.
CONDENSE L_UNITPRICE_I. " NO-GAPS.
CONCATENATE L_CPRICE_I '/' L_UNITPRICE_I W_EINE-BPRME INTO W_IFINAL-FININFPRI.
ENDIF.
W_MAIN-PEINH = W_EINE-PEINH.
CLEAR: L_CPRICE_I,
L_UNITPRICE_I,
W_EINE,
W_KONM2,
W_KONP_P,
W_EKPO,
W_KONM_P,
W_A017_P.
*--------End of Change EXT-SAP-180 23rd April 2007
ENDIF.
* MARKET PRICE
* Begin of Changes CON-SAP-99 11/12/2006 *
*clear
CLEAR : L_PERPRICE.
* End of Changes CON-SAP-99 11/12/2006 *
IF W_IFINAL-CPRICE IS NOT INITIAL.
L_PERPRICE = W_IFINAL-CPRICE.
ELSE.
L_PERPRICE = W_IFINAL-INFOREC.
ENDIF.
L_PERUNIT = W_MAIN-PEINH. " fetching the unit at contract/inforecord price level
* Begin of Changes CON-SAP-99 11/12/2006 *
W_IFINAL-MPRICE = L_PERPRICE.
* Begin of Changes EXT-SAP-180 02APR2007 *
CLEAR W_A049_T.
SORT T_A049 BY EKORG MATNR.
READ TABLE T_A049 INTO W_A049_T
WITH KEY EKORG = W_MAIN-EKORG
MATNR = W_MAIN-MATNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CLEAR: W_A049_T.
SORT T_KONP_M BY KNUMH.
LOOP AT T_A049 INTO W_A049_T "03APR07
WHERE EKORG = W_MAIN-EKORG
AND MATNR = W_MAIN-MATNR.
* Following IF condition is to check whether the dates given in the selection criteria
* are falling into the date ranges of the records of A049.
IF ( W_A049_T-DATBI GE P_VDATE -
Full Sample code for CS_BOM_EXPL_MAT_V2?
Hello, I need to get BoM simulating the transaction CS03.
That's the parameters that I enter to CS03 selection screen to get the BoM that I need:
Material 0000030
Plant 0101
BOM usage 1 Production
Alternative BOM 1
Valid from 04.04.2008 (sy-datum)
Valid to 04.04.2008 (sy-datum)
Now I'm trying to get the same result by code. But the FM doesn't return me a result. What I'm doing wrong? I've tried all the possible values of CAPID and always the result is "error material not found". Then, when I commented the field capid the result is "Error, BoM not found"...
This is my full abap code:
data : it_stb like stpox occurs 0 with header line,
it_matcat like cscmat occurs 0 with header line.
call function 'CS_BOM_EXPL_MAT_V2'
exporting
capid = 'SD01'
datuv = sy-datum
mehrs = 'X'
mtnrv = '0000030'
werks = '0101'
tables
stb = it_stb
matcat = it_matcat
exceptions
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
others = 8.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC = ', sy-subrc.
ENDIF.actually u are not passing fields stlal and stlan
see samlpe code
now to explode BOM
loop at p_it_header into wa_header .
call function 'CS_BOM_EXPL_MAT_V2'
exporting
capid = c_capid
datuv = sy-datum
mehrs = c_x
mtnrv = wa_header-matnr
stlal = wa_header-stlal
stlan = wa_header-stlan
werks = wa_header-werks
tables
stb = p_it_final
exceptions
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
others = 9.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endloop.
PLZ REWARD IF HELPFUL
VIVEK
Edited by: Vivek Gaur on Apr 4, 2008 12:06 PM -
Function to get differenece between sy-datum and any date entered in days
Dear Friends;
I have to find out the days difference between sy-datum and any valid date that come from table . Is there any function available in SAP that will give me
the difference in no. of days between sy-datum and any date that come from table??
please help me out.
Regards;
ParagJust subtract the dates from each other and you will get the number of days. I have used it and it works prefect
try this:
DATA: date1 like sy-datum,
date2 like sy-datum.
data I type i.
date1 = '20070301'.
date2 = '20070228'.
i = date1 - date2.
write: / date1, date2, i.
date1 = sy-datum.
date2 = sy-datum - 30.
i = date1 - date2.
write: / date1, date2, i.
SD_DATETIME_DIFFERENCE -
Hi all,
i am creating a BOM with item & sub item .
i am getting the error like BOM is not valid.
i am giving my coding below.plz suggest where i am doing mistake.
it's urgent.
can u plz give some sample coding where sub-item will be there in that BOM.
any idea will be highly appreaciated.
correct answers will be rewarded.
regards
pabitra
report z_bom_create
line-size 132
line-count 65.
no standard page heading.
*-- DATA DECLARATION--
include <icon> .
*---Tables
tables : s076, t100, marc .
*---Types
types : begin of t_upload, " Upload file data
col1(18),
col2(10),
col3(30),
col4(12),
col5(50),
end of t_upload,
begin of t_split,
location like stpu-ebort,
end of t_split.
*data:begin of i_return occurs 10.
*include structure bapiret2.
*data:end of i_return.
data:i_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
types:begin of t_item."occurs 10.
include structure BAPI1080_ITM_C.
types:end of t_item.
types:begin of t_subitem." occurs 10.
include structure BAPI1080_SUI_C.
types:end of t_subitem.
types:begin of t_header." occurs 10.
include structure BAPI1080_MBM_C.
types:end of t_header.
types:begin of t_bomgroup." occurs 10.
include structure BAPI1080_BGR_C.
types:end of t_bomgroup.
types:begin of t_variant." occurs 10.
include structure BAPI1080_BOM_C.
types:end of t_variant.
data:it_itemas LIKE bapi1080_rel_itm_bom_c OCCURS 0 WITH HEADER LINE,
it_subitemas LIKE BAPI1080_REL_SUI_ITM_C OCCURS 0 WITH HEADER LINE.
*--- Tables
data: i_upload type standard table of t_upload, " to hold data
i_upload1 type standard table of t_upload,
i_upload2 type standard table of t_upload,
i_split type standard table of t_split,
i_item type standard table of t_item,
i_subitem type standard table of t_subitem,
i_header type standard table of t_header,
i_bomgroup type standard table of t_bomgroup,
i_variant type standard table of t_variant.
data: wa_upload type t_upload, " to hold file data,
wa_upload1 type t_upload, " to hold plan data,
wa_upload2 type t_upload,
wa_split type t_split,
wa_item type t_item,
wa_subitem type t_subitem,
wa_header type t_header,
wa_bomgroup type t_bomgroup,
wa_variant type t_variant.
data:v_matnr like mara-matnr,
v_start like sy-index,
v_count(3) type c,
v_num(4) type c value '0000'.
*--Constants
data: c_dot type c value '.',
c_x type c value 'X',
c_comma type c value ','.
-------Selection Screen Design -
*Selection screen for input of upload file address
selection-screen skip 2.
selection-screen begin of block blk1 with frame.
parameters : p_file like rlgrap-filename obligatory .
parameters : p_matnr like mara-matnr obligatory,
p_werks like marc-werks obligatory memory id wrk,
p_stlan like afko-stlan obligatory default '1' .
selection-screen end of block blk1.
---AT SELECTION SCREEN -
*at selection-screen on value-request for p_file.
**--For popup to select file.
perform f_give_help.
*at selection-screen on p_matnr.
perform f_check_matnr.
-----START OF SELECTION -
*--Data upload using WS_Upload.
perform f_get_data.
perform f_get_bom_data.
perform f_get_bom_data1.
perform f_call_bapi.
perform f_error_display.
*& Form f_give_help
text
--> p1 text
<-- p2 text
*FORM f_give_help.
*call function 'WS_FILENAME_GET'
exporting
mask = ',.,..'
mode = 'O'
importing
filename = p_file
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
if sy-subrc <> 0 and not sy-msgty is initial.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*ENDFORM. " f_give_help
*& Form f_check_matnr
text
--> p1 text
<-- p2 text
*FORM f_check_matnr.
*CALL FUNCTION 'BAPI_MAT_BOM_EXISTENCE_CHECK'
EXPORTING
MATERIAL = p_matnr
PLANT = p_werks
BOMUSAGE = '1'
VALID_FROM_DATE =
VALID_TO_DATE =
TABLES
RETURN = i_return.
*ENDFORM. " f_check_matnr
*& Form f_get_data
text
--> p1 text
<-- p2 text
FORM f_get_data.
call function 'WS_UPLOAD'
exporting
CODEPAGE = ' '
filename = p_file
filetype = 'DAT'
tables
data_tab = i_upload
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
ENDFORM. " f_get_data
*& Form f_get_bom_data
text
--> p1 text
<-- p2 text
FORM f_get_bom_data.
delete i_upload where col1 is initial.
delete i_upload where col1 cs 'ITEM'.
i_upload2[] = i_upload[].
delete i_upload2 where col1 cs 'FINISHED GOOD'.
read table i_upload into wa_upload with key col1 = 'FINISHED GOOD:'.
if sy-subrc = 0.
v_matnr = wa_upload-col2.
if v_matnr <> p_matnr.
message e001(zl) with p_matnr.
endif.
else.
message e000(zl).
endif.
ENDFORM. " f_get_bom_data
*& Form f_get_bom_data1
text
--> p1 text
<-- p2 text
FORM f_get_bom_data1.
loop at i_upload into wa_upload where col1 CS 'FINISHED GOOD'.
v_start = sy-tabix + 1.
loop at i_upload into wa_upload1 from v_start .
if wa_upload1-col1 cs 'FINISHED GOOD'.
exit.
else.
perform f_split_upload_data.
endif.
endloop.
endloop.
ENDFORM. " f_get_bom_data1
*& Form f_split_upload_data
text
--> p1 text
<-- p2 text
FORM f_split_upload_data.
if not wa_upload1-col5 is initial.
if wa_upload1-col5 cs c_comma.
split wa_upload1-col5 at c_comma into table i_split.
loop at i_split into wa_split.
v_count = v_count + 1.
endloop.
if wa_upload1-col4 <> v_count.
wa_upload1-col4 = v_count.
endif.
clear wa_upload1-col5.
clear wa_split.
clear v_count.
loop at i_split into wa_split.
wa_upload1-col5 = wa_split-location.
append wa_upload1 to i_upload1.
endloop.
else.
append wa_upload1 to i_upload1.
endif.
else.
append wa_upload1 to i_upload1.
endif.
clear wa_upload1.
ENDFORM. " f_split_upload_data
*& Form f_call_bapi
text
--> p1 text
<-- p2 text
FORM f_call_bapi.
clear wa_upload1.
wa_header-material = p_matnr.
*wa_header-plant = p_werks.
wa_header-bom_group_identification = 'BAPI_SMP_COL1'.
wa_header-bom_usage = p_stlan.
wa_header-alternative_bom = '1'.
append wa_header to i_header.
wa_bomgroup-bom_usage = p_stlan.
*wa_bomgroup-created_in_plant = p_werks.
*wa_bomgroup-bom_group = ''.
wa_bomgroup-object_id = 'SIMPLE1'.
wa_bomgroup-bom_group_identification = 'BAPI_SMP_COL1'.
wa_bomgroup-object_type = 'BGR'.
append wa_bomgroup to i_bomgroup.
wa_variant-alternative_bom = '1'.
wa_variant-base_qty = '1.000'.
wa_variant-valid_from_date = sy-datum.
wa_variant-bom_group_identification = 'BAPI_SMP_COL1'.
wa_variant-object_type = 'BOM'.
wa_variant-object_id = 'VAR'.
wa_variant-bom_status = '1'.
wa_variant-valid_from_date = sy-datum.
wa_variant-function = 'NEW'.
append wa_variant to i_variant.
it_itemas-bom_group_identification = 'BAPI_SMP_COL1'.
it_itemas-sub_object_type = 'ITM'.
it_itemas-sub_object_id = 'SIM'.
it_itemas-super_object_type = 'BOM'.
it_itemas-super_object_id = 'VAR'.
it_itemas-valid_from_date = sy-datum.
it_itemas-function = 'NEW'.
append it_itemas.
it_subitemas-bom_group_identification = 'BAPI_SMP_COL1'.
it_subitemas-sub_object_type = 'SUI'.
it_subitemas-sub_object_id = 'SIMP'.
it_subitemas-super_object_type = 'ITM'.
it_subitemas-super_object_id = 'SIM'.
append it_subitemas.
loop at i_upload2 into wa_upload2.
*wa_item-item_id = v_num.
*v_num = v_num + 1.
wa_item-bom_group_identification = 'BAPI_SMP_COL1'.
wa_item-object_type = 'ITM'.
wa_item-object_id = 'SIM'.
wa_item-item_no = wa_upload2-col1.
wa_item-item_cat = wa_upload2-col2.
wa_item-component = wa_upload2-col3.
wa_item-comp_qty = wa_upload2-col4.
wa_item-valid_from_date = sy-datum.
append wa_item to i_item.
endloop.
loop at i_item into wa_item.
loop at i_upload1 into wa_upload1 where col1 = wa_item-item_no.
wa_subitem-bom_group_identification = 'BAPI_SMP_COL1'.
wa_subitem-object_type = 'SUI'.
wa_subitem-object_id = 'SIMP'.
IF not wa_upload1-col5 is initial.
on change of wa_upload1-col5.
v_num = v_num + 1.
wa_subitem-subitem_no = v_num.
wa_subitem-subitem_qty = '1'.
wa_subitem-installation_point = wa_upload1-col5.
append wa_subitem to i_subitem.
clear wa_subitem.
endon.
endif.
clear wa_upload1.
endloop.
clear v_num.
clear wa_upload.
endloop.
CALL FUNCTION 'BAPI_MATERIAL_BOM_GROUP_CREATE'
EXPORTING
TESTRUN = ' '
ALL_ERROR = ' '
TABLES
BOMGROUP = i_bomgroup
VARIANTS = i_variant
ITEMS = i_item
SUBITEMS = i_subitem
MATERIALRELATIONS = i_header
ITEMASSIGNMENTS = it_itemas
SUBITEMASSIGNMENTS = it_subitemas
TEXTS =
RETURN = i_return.
*if i_return[] is initial.
*CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
*write: /'BOM created:', stpo-stlnr.
*else.
*if not i_return[] is initial.
*loop at i_return.
WRITE:/ i_return-type, i_return-id, i_return-number,
i_return-message.
*ENDLOOP.
IF i_return-TYPE = 'E'.
errmsg-type = i_return-type.
errmsg-line = i_return-message.
append errmsg.
ULINE /1(108).
write:/ icon_led_RED as icon, i_return-MESSAGE.
ULINE /1(108).
ENDIF.
IF i_return-TYPE = 'W'.
errmsg-type = i_return-type.
errmsg-line = i_return-message.
append errmsg.
ULINE /1(108).
write:/ icon_led_YELLOW as icon, i_return-MESSAGE.
ULINE /1(108).
ENDIF.
ENDLOOP.
**write: / i_return-id, i_return-number, i_return-message(80).
**endloop.
**write: /'Error'.
**endif.
ENDFORM. " f_call_bapi
*& Form f_error_display
text
--> p1 text
<-- p2 text
FORM f_error_display.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
loop at i_return.
WRITE:/ i_return-type, i_return-id, i_return-number,
i_return-message.
ENDLOOP.
ENDFORM. " f_error_displayAre u sure That BAPI is the right one to use to create BOM , I think this Error is coming from BAPI itself So try to Debug the BAPI from where its throwing the error.
Regards
prabhu -
Hi
This is my existing interface ,I need to do a validation on Unique id,which i need to add to custom table ZBACKS_GIPD.
Check if there is same unique id within the upload file.
Check from table ZBACKS_GIPD if the same Unique ID already exists ,
Update log file with error message :"Duplicate record"
Please let me know where I need to add this validation in the below code.
REPORT ZBAB005 LINE-SIZE 255
LINE-COUNT 58(2)
NO STANDARD PAGE HEADING
MESSAGE-ID 00.
TABLES: MARA, "Material master
MARC, "Plant Data for Material
MBEW, "Material Valuation
T001K, "Valuation area
t100, "Messages
kna1, "Customer master
SKB1, "G/L account
BKPF, "FIN doc
zprdordhdr, "production order header
ZSTDLOADING, "BACKS-SAP Interface - Generic ProdOrd costing data
ZBACKS_GIPD. "BACKS-SAP Interface - Material Consumption
Short name of the interface name
DATA: INTFNAME(4) value 'GIPD'. "Good Issues for Prod. Order
include zbab000. "Common procedures for files handling
SELECTION-SCREEN BEGIN OF BLOCK 6 WITH FRAME TITLE TEXT-006.
parameters: p_usafl obligatory default 'E'. "Usgae indicator
parameters: p_chk_ui as checkbox "check invalid usage ind "UATK922842
default space. "UATK922842
parameters: p_chk_pd as checkbox "check period of the posting date
default 'X'. "UATK923027
SELECTION-SCREEN END OF BLOCK 6.
SELECTION-SCREEN BEGIN OF BLOCK 7 WITH FRAME TITLE TEXT-007.
parameters: fb70mode default 'N'.
parameters: fb50mode default 'N'.
SELECTION-SCREEN END OF BLOCK 7.
SELECTION-SCREEN BEGIN OF BLOCK 8 WITH FRAME TITLE TEXT-008.
parameters:
p_nor radiobutton group rad1, "new posting
p_rep2 radiobutton group rad1. "report (flag '2')
select-options:
recno for zbacks_gipd-recno "record number
default '1' obligatory.
SELECTION-SCREEN END OF BLOCK 8.
DATA: BEGIN OF TAB OCCURS 1000,
WERKS(04), "plant
AUFNR(25), "production order number
MATNR(18), "material
ERDAT(10), "BACKS tx date
MENGE_as_string(17), "qty
USAFL(01), "consumption/usage indicator
SAKNR(10), "G/L account number (this is from user's data file,
"use SAKNR_FOR_POSTING to post mat. doc instead)
EXPCD(02), "expenses code
IDNUM(35), "BACKS Identification number
kunnr(10), "customer number
The below 3 fields have no use in SAP transactions
however they are included in the data file from BACKS.
Just store them in ZBACKS_GIPD for future use if required
USACD(10), "usage code
ORDCD(10), "order code
LOSTY(03), "loss type
COTAX(13), " like zbacks_gipd-cotax, "consumption tax
MWSKZ(02), " like zbacks_gipd-MWSKZ, "tax code
The below fields are not included in the BACKS incoming data file
They are only for the processing of this program
RECNO(10), "record number in the uploaded data file
FAILF(01), "Status flag (0=OK, see documentation for details)
MSGNR(01), "message number
MSGTX(200), "message text
menge(13) type p decimals 3, "qty as numeric
BUKRS like t001-bukrs, "company code
PRCTR like marc-prctr, "profit center
matkl like mara-matkl, "material group
unitstdcost type p decimals 3,"standard cost (per 1 EA)
matloading type i, "material loading
runum like zprdordhdr-runum,"prod. order running number
SAKNR like zexpense-saknr, "account no.
KOSTL like zexpense-kostl, "cost center
saknr_for_posting like bseg-saknr,"G/L acct after validation
erdat_raw(10), "BACKS tx date (MM/DD/YYYY)
**>>1104
post_seq_ORIG like DATATYPE-INTEGER4,
"(5) type n, "random number: posting order
post_seq_RAND like DATATYPE-INTEGER4,
"(5) type n, "random number: posting order
**>>1104
MATDOC(10), "material document
MATDOCITEM(4), "material document item number
Direction(1), "I=Issue, R=Reverse (based on the +/- of MENGE)
ladra like zbacks_gipd-ladra, "material loading rate
hdr_SUBPR like zprdordhdr-SUBPR, "Sub-con Prodorder "UATK922842
the below 2 fields are added to resolve 1-yen issue "DEVK914235
STOCKQTY like ZBACKS_GIPD-STOCKQTY, "total stock (from MBEW)
SALK3 like ZBACKS_GIPD-SALK3, "total value before issue
ISSUESTPRS like ZBACKS_GIPD-ISSUESTPRS,"unit std cost
END OF TAB.
data: START_RECNO like ZBACKS_GIPD-recno.
DATA: BEGIN OF BDCDATA OCCURS 100.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.
data: begin of msgtab occurs 0.
INCLUDE STRUCTURE BDCMSGCOLL.
data: end of msgtab.
Constants used in A/C & Inv postings *
for JV posting
CONSTANTS:
CONST_SAKNR_WIP_LABOUR_OH like BSEG-SAKNR "G/L act: WIP-Labour & O/H
value '0000141000',
CONST_SAKNR_WIP_MAT_LOAD like BSEG-SAKNR "G/L act: WIP Matl. Loading
value '0000543004',
CONST_SAKNR_WIP_MAT like BSEG-SAKNR "G/L act: WIP matl
value '0000140000',
CONST_SAKNR_OTHER_INCOME like BSEG-SAKNR "G/L act: Other income
value '0000725000', "was: '0000400310',
CONST_SAKNR_WIP_MAT_SUB_CON like BSEG-SAKNR "G/L act: Mat supplied
value '0000126001'. "to subcontractor
for material movement (inventory posting)
CONSTANTS:
CONST_LGORT like mseg-LGORT "storage location
value 'STR1',
CONST_CHARG like mseg-charg "batch number
value 'BACKS'.
for AR customer invoice for sub-contractor
CONSTANTS:
CONST_TAX_RATE type p decimals 2 value '0.05', "i.e. 5%
CONST_PENALTY_RATE type p decimals 2 value '0.2'. "i.e. 20%
Structures & internal tables for BAPI - Material movement *
Header segment with control information
DATA: BEGIN OF GOODSMVT_HEADER OCCURS 0.
INCLUDE STRUCTURE BAPI2017_GM_HEAD_01.
DATA: END OF GOODSMVT_HEADER.
DATA: BEGIN OF GOODSMVT_CODE OCCURS 0.
INCLUDE STRUCTURE BAPI2017_GM_CODE.
DATA: END OF GOODSMVT_CODE.
DATA: BEGIN OF GOODSMVT_ITEM OCCURS 0.
INCLUDE STRUCTURE BAPI2017_GM_ITEM_CREATE.
DATA: END OF GOODSMVT_ITEM.
DATA: BEGIN OF REMSG OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF REMSG.
DATA: BEGIN OF GOODSMVT_HEADRET OCCURS 0.
INCLUDE STRUCTURE BAPI2017_GM_HEAD_RET.
DATA: END OF GOODSMVT_HEADRET.
*DATA: MATDOC LIKE BAPI2017_GM_HEAD_RET-MAT_DOC.
DATA: DOCYEAR LIKE BAPI2017_GM_HEAD_RET-DOC_YEAR.
Structures & internal tables for BAPI - Account Doc Posting *
DATA: DOCUMENTHEADER like BAPIACHE08.
DATA: BEGIN OF ACCOUNTGL occurs 0.
include structure BAPIACGL08.
DATA: END OF ACCOUNTGL.
DATA: BEGIN OF CURRENCYAMOUNT occurs 0.
include structure BAPIACCR08.
DATA: END OF CURRENCYAMOUNT.
DATA: BEGIN OF RETURN occurs 0.
include structure BAPIRET2.
DATA: END OF RETURN.
Misc. internal tables and variable for error logging *
DATA: BEGIN OF ERRTX OCCURS 0,
MSGTX(110).
DATA: END OF ERRTX.
DATA: ERR(1) TYPE C.
TTLQTY(12) TYPE P,
SUCQTY(12) TYPE P,
FALQTY(12) TYPE P.
Calculation variables for sub-contractor *
data: ar_amt_vendor type p decimals 0.
data: ar_amt_penalty type p decimals 0.
data: ar_amt_total type p decimals 0.
data: ar_amt_tax type p decimals 0.
data: ar_amt_vendor_as_text(13).
data: ar_amt_penalty_as_text(13).
data: ar_amt_total_as_text(13).
data: ar_amt_tax_as_text(13).
data: last_werks like tab-werks. "plant
data: last_matnr like tab-matnr. "to avoid locking problem -> Sleep if
"the current p/n is the same as the last one
data: last_direction.
DATA: FI_DOC_TEXT(50). "contains: 1-35: BACKS ID
" 36-50: Quantity
data: begin of tab_by_matnr occurs 0.
include structure tab.
data: end of tab_by_matnr.
data: MATDOC_AND_ITEM(16). "to put in reference fields
Data for mat doc item rearrangement *
*Max. no. of items in a single material doc.
*This number must be less than the half of the FI doc. item limit (999)
constants:
c_max_mat_doc_items type i value '400'.
last flag to indicate if a break is required
data: l_last_matnr like tab-matnr. "last material
data: l_last_direction like tab-direction. "last direction (+ or -)
data: l_last_werks like tab-werks. "last plant
count the no. of items (to check against the max. no. of item limit)
data: l_matnr_counter type i.
Start and End date of the allowed posting priod *
data: g_period_start_date like sy-datum. "first date of current period
data: g_period_end_date like sy-datum. "end date of current period
Stock info before Goods issue (to solve 1-yen issue) *
data: G_SALK3(16) type p decimals 0. "total stock value
data: G_LBKUM like mbew-lbkum. "total stock qty
T O P O F P A G E
TOP-OF-PAGE.
CALL FUNCTION 'Z_PRINT_REPORT_HEADING'
EXPORTING
I_WERKS = 'IHK1'
I_LINSZ = SY-LINSZ
I_CPROG = SY-CPROG
I_TITLE = SY-TITLE.
WRITE: /1(006) 'Plant' color 1,
(025) 'Production Order No' color 1,
(018) 'Material' color 1,
(010) 'CreDate' color 1,
(015) 'Qty' color 1,
(010) 'Usage Ind.' color 1,
(010) 'G/L Acct.' color 1,
(025) 'BACKS ID' color 1,
(010) 'Cust.No.' color 1,
(001) 'Fail Flag' color 1,
(100) 'Message' color 1.
ULINE.
START - OF - SELECTION *
START-OF-SELECTION.
if p_chk_pd = 'X'. "check preiod is needed "UATK923027
perform start_end_date_of_period. "calculate period start/end date
if g_period_start_date is initial "if the start/end date is not
or g_period_end_date is initial. "determined, stop the program
write: / 'Period start/end date not determined, program stopped.'.
stop.
endif.
endif.
if p_nor = 'X'.
PERFORM COMMON_SETUP_FILENAMES. "auto setup filenames by current date
PERFORM COMMON_UPLOAD_FILES. "upload input files: TXT and FLG
PERFORM CONVERSION_DATA.
elseif p_rep2 = 'X'.
perform read_data_from_GIPD.
endif.
PERFORM CHECK_DATA.
PERFORM MAIN_UPDATE.
PERFORM PRINT_OUTPUT.
PERFORM COMMON_DOWNLOAD_FILES. "download the log & status file
FORM READ_DATA_FROM_GIPD *
form read_data_from_GIPD.
select * from zbacks_gipd
where failf = '2'
and recno in recno.
clear tab.
clear result_total. "reset the record counter
tab-werks = zbacks_gipd-WERKS. "plant
tab-aufnr = zbacks_gipd-AUFNR. "production order no.
tab-matnr = zbacks_gipd-MATNR. "material
tab-erdat = zbacks_gipd-BUDAT. "transaction date
tab-recno = zbacks_gipd-recno.
TAB-MENGE = zbacks_gipd-menge. "qty
TAB-USAFL = zbacks_gipd-usafl. "usage/consumption ind.
TAB-EXPCD "Expenses code
TAB-SAKNR = zbacks_gipd-saknr. "G/L account number
TAB-IDNUM = zbacks_gipd-idnum. "BACKS identification no.
TAB-KUNNR = zbacks_gipd-kunnr. "Customer Number
TAB-USACD = zbacks_gipd-usacd. "usage code
TAB-ORDCD = zbacks_gipd-ordcd. "order code
TAB-LOSTY = zbacks_gipd-losty. "loss type
TAB-COTAX = zbacks_gipd-cotax. "consumption tax
TAB-MWSKZ = zbacks_gipd-mwskz. "tax code
tab-runum = zbacks_gipd-runum. "running number
tab-failf = zbacks_gipd-failf. "failure flag
tab-msgnr = zbacks_gipd-failf. "failure flag
tab-matdoc = zbacks_gipd-docm1. "material doc
tab-msgtx = 'Repost 2nd step'.
tab-erdat_raw = tab-erdat. "keep the MM/DD/YYYY format
CONCATENATE TAB-ERDAT6(4) TAB-ERDAT0(2) TAB-ERDAT+3(2)
INTO TAB-ERDAT.
concatenate tab-erdat+4(2) '/'
tab-erdat+6(2) '/'
tab-erdat+0(4)
into tab-erdat_raw.
*Process only a particular set of usage indicator first
if tab-usafl = p_usafl.
APPEND TAB.
result_total = result_total + 1. "Increase the record counter
endif.
endselect.
write: / 'Re-processing records for usage indicator', p_usafl.
endform.
FORM CONVERSION_DATA *
FORM CONVERSION_DATA.
data: saknr_len type i. "field length of GL acct
data: kunnr_len type i. "field length of cust no.
describe field tab-saknr length saknr_len.
describe field tab-kunnr length kunnr_len.
clear result_total. "reset the record counter
LOOP AT STR_TXT.
CLEAR TAB.
SPLIT STR_TXT-SLINE AT '|'
INTO TAB-WERKS "plant
TAB-AUFNR "production order no.
TAB-MATNR "material
TAB-ERDAT "transaction date
TAB-MENGE_as_string "qty
TAB-USAFL "usage/consumption ind.
TAB-EXPCD "Expenses code
TAB-SAKNR "G/L account number
TAB-IDNUM "BACKS identification no.
TAB-KUNNR "Customer Number
TAB-USACD "usage code
TAB-ORDCD "order code
TAB-LOSTY "loss type
TAB-COTAX "consumption tax
TAB-MWSKZ "tax code
tab-erdat_raw = tab-erdat. "keep the MM/DD/YYYY format
CONCATENATE TAB-ERDAT6(4) TAB-ERDAT0(2) TAB-ERDAT+3(2)
INTO TAB-ERDAT.
tab-menge = tab-menge_as_string. "convert to numeric field
*set tab-msgnr to 1 for invalid usage indicator
*so that the error records will be included in the error log
if p_chk_ui = 'X'.
perform check_usage_indicator.
endif.
*Process only a particular set of usage indicator first
*{Gary Tang 02/10/2003 UATK922842 also include MSGNR=1 (invalid usage
*incicator records
if tab-usafl = p_usafl "this is the target usage indicator
or tab-msgnr = '1'. "this is 1 because of invalid usage ind.
*}Gary Tang 02/10/2003 UATK922842
add leading zero to numeric GL acct no.
e.g. data file: 230330 --> convert to: 0000230330
CALL FUNCTION 'Z_PURE_NUMERIC_ADD_LEADING_0'
EXPORTING
INPUT_FIELD = tab-saknr
TARGET_LEN = saknr_len
IMPORTING
OUTPUT_FIELD = tab-saknr
add leading zero to numeric cust num
e.g. data file: 3100001 --> convert to: 0003100001
e.g. data file: NEC-JP --> no conversion: NEC-JP
CALL FUNCTION 'Z_PURE_NUMERIC_ADD_LEADING_0'
EXPORTING
INPUT_FIELD = tab-kunnr
TARGET_LEN = kunnr_len
IMPORTING
OUTPUT_FIELD = tab-kunnr
APPEND TAB.
result_total = result_total + 1. "Increase the record counter
endif.
ENDLOOP.
write: / 'Processing records for usage indicator', p_usafl.
ENDFORM.
FORM CHECK_DATA *
FORM CHECK_DATA.
if p_nor = 'X'.
PERFORM GET_NEXT_RECNO.
endif.
LOOP AT TAB.
perform check_data_on_period."record date must in current period
perform check_data_on_zprdordhdr. "production order header
perform check_data_on_mara. "material master (general)
perform check_data_on_marc. "material master (plant)
perform check_data_on_t001k. "company code vs plant
perform check_data_on_mbew. "Material Valuation
perform check_usage_indicator. "usage indicator
perform check_sub_contract. "must have customer number
perform check_data_on_kna1. "customer number
perform check_data_on_skb1. "G/L account
perform check_menge. "quantity
perform check_expense. "for eXpenses
perform calculate_materail_loading.
perform gen_random_posting_sequence.
if p_nor = 'X'.
PERFORM INSERT_TABLE_ZBACKS_GIPD.
endif.
MODIFY TAB.
endloop.
if p_nor = 'X'.
print the last record number for reference
write: / 'ZBACKS_GIPD record number (RECNO) to :',
ZBACKS_GIPD-RECNO.
skip 1.
endif.
endform.
FOMR Gen_random_posting_sequence *
*form gen_random_posting_sequence.
tab-post_seq_ORIG = SY-TABIX.
if tab-msgnr = '1'. "no need to go further if already rejected
tab-post_seq_RAND = 0.
else.
CALL FUNCTION 'RANDOM_I4'
EXPORTING
RND_MIN = 1
RND_MAX = 50000
IMPORTING
RND_VALUE = tab-Post_seq_RAND
endif.
*endform.
FOMR CHECH_MENGE *
form check_MENGE.
if tab-menge > 0. "Issue qty > 0
tab-direction = 'I'. "Issue (i.e. decrease the inventory)
elseif tab-menge < 0. "Issue qty < 0
tab-direction = 'R'. "Reverse (i.e. increase the inventory
elseif tab-menge = 0. "Issue qty = 0 ==> Strange case, error!
TAB-MSGNR = '1'.
tab-msgtx = 'Qty is 0. Nothing to post!'.
endif.
endform.
FOMR CHECH_USAGE_INDICATOR *
form check_usage_indicator.
case tab-usafl.
when 'I'. "Inhouse production
when 'E'. "External procurement
when 'X'. "Expense
when 'T'. "transfer to sub-contractor
when 'S'. "sale to sub-contractor
when 'C'. "consign to sub-contractor
when '?'. "add new usage indicator here if needed!
when others. "illegal value! reject the record
TAB-MSGNR = '1'.
concatenate 'Invalid usage indicator'
into tab-msgtx separated by space.
tab-msgtx = 'Invalid usage indicator'.
endcase.
endform.
*form check_expense.
check not tab-msgnr = '1'. "no need to go further if already rejected*
check tab-usafl = 'X'. "only for expense
SELECT SINGLE ZEXPENSE~SAKNR
ZEXPENSE~KOSTL
into (TAB-SAKNR,
TAB-KOSTL)
FROM ZEXPENSE
WHERE ZEXPENSE~WERKS = TAB-WERKS
AND ZEXPENSE~EXPCD = TAB-EXPCD.
IF SY-SUBRC <> 0.
TAB-MSGNR = '1'.
TAB-MSGTX = 'Expense code not found (ZEXPENSE)'.
endif.
*endform.
FOMR CALCULATE_MATERIAL_LOADING *
form calculate_materail_loading.
check not tab-msgnr = '1'. "no need to go further if already rejected
*Material loading is calculated for all records
*Though posting only required for usage 'E'
check tab-usafl = 'E'. "only for External procurement need to post
select single ZSTDLOADING~LADRA "loading %
into ZSTDLOADING-LADRA "loading %
from ZSTDLOADING "standard loading info.
where WERKS = tab-werks "plant
and MATGP = tab-matkl+0(2) "customer code
and LADTY = tab-usafl. "usage code
and LADTY = 'P'. "material loading
if ( sy-subrc <> 0 ).
or ( zstdloading-LADRA is initial ). "DEVK909574
TAB-MSGNR = '1'.
TAB-MSGTX = 'Mat. loading % not found or = 0% (ZSTDLOADING)'.
else.
tab-ladra = zstdloading-ladra. "store the loading rate into table
*{Gary Tang 02/10/2003 "UATK922842
round the qty*stdcost to integer before multiplying the loading rate
tab-matloading "type is integer (result will be rounded off)
= tab-menge "qty
tab-unitstdcost. "std cost (of 1 EA)
* ZSTDLOADING-LADRA "material loading percentage (%)
/ 100. "because material loading is in %
tab-matloading "type is integer (result will be rounded off)
= tab-matloading
ZSTDLOADING-LADRA "material loading percentage (%)
/ 100. "because material loading is in %
*}Gary Tang 02/10/2003 "UATK922842
endif.
endform.
FORM CHECK_DATA_ON_SKB1 *
form check_data_on_SKB1.
data: saknr_as_numeric(10) type n. "for leading zero
check not tab-msgnr = '1'. "no need to go further if already rejected
case tab-usafl.
when 'I' or 'E' or 'C'.
if not tab-saknr is initial.
TAB-MSGNR = '1'.
concatenate 'G/L Account no. should be blank for usage indicator'
tab-usafl into tab-msgtx separated by space.
else.
tab-saknr_for_posting = CONST_SAKNR_WIP_MAT.
endif.
when 'T' or 'S'.
if not tab-saknr is initial.
TAB-MSGNR = '1'.
concatenate 'G/L Account no. should be blank for usage indicator'
tab-usafl into tab-msgtx separated by space.
else.
tab-saknr_for_posting = CONST_SAKNR_WIP_MAT_SUB_CON.
endif.
when 'X'. "G/L acct is required for eXpense
if tab-saknr is initial.
TAB-MSGNR = '1'.
concatenate 'G/L Account no. is REQUIRED for usage indicator'
tab-usafl into tab-msgtx separated by space.
else.
CATCH SYSTEM-EXCEPTIONS CONVT_NO_NUMBER = 4.
SAKNR_AS_NUMERIC = TAB-SAKNR.
endcatch.
if sy-subrc = 4.
TAB-MSGNR = '1'.
TAB-MSGTX = 'Invild G/L acct no. (should be numeric)'.
endif.
select single skb1~saknr
into skb1-saknr
from skb1
where skb1~bukrs = tab-bukrs
and skb1~saknr = saknr_as_numeric. " tab-saknr.
if sy-subrc = 0.
tab-saknr_for_posting = saknr_as_numeric. " tab-saknr.
else.
TAB-MSGNR = '1'.
TAB-MSGTX = 'G/L Account no. not found (SKB1)'.
endif.
endif.
endcase.
endform.
FORM CHECK_DATA_ON_PREIOD *
form check_data_on_period.
check p_chk_pd = 'X'. "check period option is selected
check not tab-msgnr = '1'. "no need to go further if already rejected
if tab-erdat < g_period_start_date "record in past period, reject!
or tab-erdat > g_period_end_date. "record in future period, reject!
TAB-MSGNR = '1'.
TAB-MSGTX = 'Record date is not in open period.'.
endif.
endform.
FORM CHECK_DATA_ON_MBEW *
form check_data_on_mbew.
data: local_stprs like mbew-stprs. "std price
data: local_peinh like mbew-peinh. "price unit
check not tab-msgnr = '1'. "no need to go further if already rejected
*Standard cost is checked for all records
*Though calculation is only required for usage 'E'
check tab-usafl = 'E' "for External procurement
or tab-usafl = 'T' "for Transfer to sub-contractor
or tab-usafl = 'S'."for Sale to sub-contractor
select single stprs "std price
peinh "price unit
into (local_stprs, "std price
local_peinh) "price unit
from mbew "material valuation
where matnr = tab-matnr "material
and bwkey = tab-werks. "plant
if ( sy-subrc <> 0 ) "record not round
or ( local_stprs = 0 ). "std cost = 0 (should not happen)
TAB-MSGNR = '1'.
TAB-MSGTX = 'Standard cost not found or = 0 (MBEW)'.
else. "calculate the cost of 1 EA
tab-unitstdcost = local_stprs / local_peinh * 100.
endif.
endform.
FORM CHECK_DATA_ON_ZPRDORDHDR *
form check_data_on_zprdordhdr.
check not tab-msgnr = '1'. "no need to go further if already rejected
Production order is not required for usage indicator 'T' or 'S'
Even the number is provided, it may or may not exist in ZPRDORDHDR
Therefore, all checking on production order can be skipped for T & S
(11/11/2002, confirmation from Stephen Chung, Miura-san, Sato-san)
check tab-usafl <> 'T' "Transfer to sub-contract
and tab-usafl <> 'S' "Sales to sub-contract
Confirmed by Miura-san on 11/30/2002
Production order no. is also not required for 'X' (Expense)
and tab-usafl <> 'X'. "Expenses
if tab-aufnr is initial.
TAB-MSGNR = '1'.
TAB-MSGTX = 'Production order number is missing'.
exit.
endif.
select single zprdordhdr~aufnr
into zprdordhdr-aufnr
from zprdordhdr
where zprdordhdr~werks = tab-werks
and zprdordhdr~aufnr = tab-aufnr.
if sy-subrc <> 0.
TAB-MSGNR = '1'.
TAB-MSGTX = 'Production order number not found (ZPRDORDHDR)'.
else.
select max( zprdordhdr~runum )
into tab-runum
from zprdordhdr
where zprdordhdr~werks = tab-werks
and zprdordhdr~aufnr = tab-aufnr.
if tab-runum is initial.
TAB-MSGNR = '1'.
TAB-MSGTX = 'Production order number not found (ZPRDORDHDR)'.
else.
select single
stats "production order status
SUBPR "Sub-contracting Production Order
into (zprdordhdr-stats,
tab-hdr_SUBPR) "save into internal table TAB directly!
from zprdordhdr
where zprdordhdr~werks = tab-werks
and zprdordhdr~aufnr = tab-aufnr
and zprdordhdr~runum = tab-runum.
if ( zprdordhdr-stats <> 'O' )
and ( zprdordhdr-stats <> 'C' ).
TAB-MSGNR = '1'.
concatenate 'No tx is allowed, production order in status'
zprdordhdr-stats into tab-msgtx separated by space.
endif.
endif.
endif.
endform.
FORM CHECK_DATA_ON_MARA *
form check_data_on_mara.
check not tab-msgnr = '1'. "no need to go further if already rejected
get cost center that is from profit center in MARC
SELECT SINGLE MARA~MATKL "material group
into MARA-MATKL "material group
FROM MARA "Material master
WHERE MATNR = TAB-MATNR. "material
IF SY-SUBRC = 0.
TAB-MATKL = MARA-MATKL. "material group
ELSE.
TAB-MSGNR = '1'.
TAB-MSGTX = 'Material not found (mat.gp./cust code missing) (MARA)'.
ENDIF.
ENDFORM.
FORM CHECK_DATA_ON_MARC *
form check_data_on_marc.
check not tab-msgnr = '1'. "no need to go further if already rejected
get cost center that is from profit center in MARC
SELECT SINGLE PRCTR
into MARC-PRCTR
FROM MARC "Plant Data for Material
WHERE MATNR = TAB-MATNR "material
AND WERKS = TAB-WERKS. "plant
IF SY-SUBRC EQ 0.
TAB-PRCTR = MARC-PRCTR. "profit center
ELSE.
TAB-MSGNR = '1'.
TAB-MSGTX =
'Mat. not found in plant. (Profit center missing) (MARC)'.
ENDIF.
ENDFORM.
FORM CHECK_DATA_ON_KNA1 *
form check_data_on_kna1. "customer number
data: kunnr_as_numeric(10) type n.
data: kunnr_as_string(10).
check not tab-msgnr = '1'. "no need to go further if already rejected
check not tab-kunnr is initial.
IF NOT TAB-KUNNR CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,-_#'.
kunnr_as_numeric = tab-kunnr.
kunnr_as_string = kunnr_as_numeric.
else.
kunnr_as_string = tab-kunnr.
ENDIF.
select single kna1~kunnr
into kna1-kunnr
from kna1
where kunnr = kunnr_as_string. " tab-kunnr.
where kunnr = tab-kunnr. "customer no. (w/ leading zero if numeric)
if sy-subrc <> 0.
TAB-MSGNR = '1'.
concatenate 'Customer number' tab-kunnr 'not found (KNA1)'
into tab-msgtx separated by space.
ENDIF.
endform.
FORM CHECK_Sub_contract *
form check_sub_contract.
check not tab-msgnr = '1'. "no need to go further if already rejected
if tab-kunnr is initial.
if ( tab-usafl = 'T' )
or ( tab-usafl = 'S' ).
TAB-MSGNR = '1'.
concatenate 'Cust number should not be blank for usage indicator'
tab-usafl into tab-msgtx separated by space.
endif.
else.
if ( tab-usafl <> 'T' )
and ( tab-usafl <> 'S' ).
TAB-MSGNR = '1'.
concatenate 'Cust. number should be blank for usage indicator'
tab-usafl into tab-msgtx separated by space.
endif.
endif.
endform.
FORM CHECK_DATA_ON_t001k *
form check_data_on_t001k.
check not tab-msgnr = '1'. "no need to go further if already rejected
select single * from t001k "Valuation area
where bwkey = tab-werks. "plant
if sy-subrc = 0.
tab-bukrs = t001k-bukrs. "company code
else.
TAB-MSGNR = '1'.
concatenate 'Company code not found for plant'
tab-werks '(T001K)'
into tab-msgtx separated by space.
endif.
endform.
FORM POST_GOODS_ISSUE *
form post_goods_issue.
perform UPDATE_GI_FOR_COST_CTR.
clear FI_DOC_TEXT.
FI_DOC_TEXT+0(35) = tab-idnum.
write: tab-menge to FI_DOC_TEXT+35(15) right-justified.
write: / '**', tab-matdoc, '**'.
endform.
FORM MAIN_UPDATE *
FORM MAIN_UPDATE.
data: current_lock_matnr like mara-matnr.
*>>1104
sort tab by post_seq_RAND ascending.
*>>1104
Direction: I=Issue, R=Reverse
Do reverse first since it will increase invenotry
sort tab by direction descending "R first, then I
werks ascending
matnr ascending. "Sort by plant and then material
if p_nor = 'X'. "new posting first step
read the first record into the last flag to avoid problem when
processing the 1st record
loop at tab where msgnr <> '1'. "skip the rejected records
last_matnr = tab-matnr.
last_direction = tab-direction.
last_werks = tab-werks.
exit.
endloop.
loop at tab where msgnr <> '1'. "skip the rejected records
if ( tab-werks <> last_werks )
or ( tab-matnr <&Yes I had solved this
-
Validation F110 automatic payment
Hello Gurus.
At this moment i trying to validate the posting date on T-CODE F110, i created a validation for this field but is not working.
Does somebody has any idea how can i validate this field in TCODE F110?
What i need is the posting date in TCODE F110 >= current date.
Any help is welcome
Regards.
RVPThis is the validation that already did and is working properly for TCODE F-58 but not for TCODE F110.
Prerequisite: SYST-TCODE = 'F-58' OR SYST-TCODE = 'F110' OR SYST-TCODE = 'FBZ4'
Check: BKPF-BUDAT > SYST-DATUM
Message: Posting date must be greater than current date.
I tried to use the trace for the tcode F110 but it doesn´t work.
Thanks for your time.
I solved the problem using a Field Exit.
Edited by: Rafael Vazq on May 18, 2010 9:37 AM
Edited by: Rafael Vazq on May 18, 2010 9:41 AM -
Hi friends i am new to abap.i am doing some validation in my report .my program is executing properly but i need some modification.... its alv report on bapi for GOODS MOVEMENT TYPE For tht i am uploading a flat file using gui_upload.but i need some modification on validation..this program is abt goods transfer from one plant to another plant,s location .so in my flat file i am having material,from plant ,from location,to plant,to location and quantity .here is the code:
*& Form VALIDATE_DATA
1.Check Material in Table MARC >> Material Plant Validation
If not found, Fill Remarks with 'Material Not Found in Plant'
2.Check Plant is Assigned to POrg in Table T024W >> Plant POrg Validation
If not found, Fill Remarks with 'Invalid POrg for Plant'
3.Check Location for Plant and Location in Table T001L >> Plant SLoc Validation
If not found, Fill Remarks with 'Invalid Storage Location for Plant'
FORM validate_data .
DATA: lv_ekorg TYPE t024e-ekorg.
Get POrg for CompanyCode
SELECT SINGLE ekorg INTO lv_ekorg FROM t024e
WHERE bukrs EQ p_bukrs.
LOOP AT it_final.
Check-1
SELECT SINGLE * FROM marc
WHERE matnr = it_final-matnr
AND werks = it_final-f_werks.
IF sy-subrc = 4.
it_final-remark = 'Material Not Found in Plant'.
MODIFY it_final.
ELSE.
Check-2
SELECT SINGLE * FROM t024w
WHERE werks = it_final-t_werks
AND ekorg = lv_ekorg.
IF sy-subrc = 4.
it_final-remark = 'Invalid POrg for Plant'.
MODIFY it_final.
ELSE.
Check-3
SELECT SINGLE * FROM t001l
WHERE werks = it_final-t_werks
AND lgort = it_final-t_lgort.
IF sy-subrc = 4.
it_final-remark = 'Invalid Storage Location for Plant'.
MODIFY it_final.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " VALIDATE_DATA
for this code i am getting output as if plant value is wrong then there will be a remark in the output as material is 'Material Not Found in Plant'....and as same for location n purchase organization....
But in my output i want ,if there is plant n location is wrong the then 2 remarks should display in 2 rows but like wise now i am getting only one remark for 2 errors also..........getting remark based on first condition....
can any one help me hw to solve ...*& Report YSG_IM_F2_002 *
*& This object is for goods transfer from one plant to another *
*& plant using FM-BAPI_GOODSMVT_CREATE *
REPORT YSG_IM_F2_002 .
TABLES: marc, t024w, t001l.
TYPE-POOLS:slis.
TYPES: BEGIN OF i_list,
matnr LIKE mard-matnr,
f_werks LIKE mard-werks,
f_lgort LIKE mard-lgort,
t_werks LIKE mard-werks,
t_lgort LIKE mard-lgort,
labst LIKE mard-labst,
remark TYPE c,
END OF i_list.
TYPES: BEGIN OF i_mara,
matnr LIKE mara-matnr,
END OF i_mara.
TYPES:BEGIN OF i_marc,
matnr LIKE marc-matnr,
werks LIKE marc-werks,
END OF i_marc.
TYPES: BEGIN OF i_mard,
matnr LIKE mard-matnr,
f_werks LIKE mard-werks,
f_lgort LIKE mard-lgort,
t_werks LIKE mard-werks,
t_lgort LIKE mard-lgort ,
labst LIKE mard-labst,
END OF i_mard.
TYPES: BEGIN OF i_t001l,
bukrs TYPE t001l-werks,
lgort TYPE t001l-lgort,
END OF i_t001l.
TYPES: BEGIN OF i_t024e,
ekorg TYPE t024e-ekorg,
bukrs TYPE t024e-bukrs,
END OF i_t024e.
TYPES: BEGIN OF i_mkpf,
xblnr type mkpf-xblnr,
END OF i_mkpf.
TYPES: BEGIN OF i_final,
matnr LIKE mard-matnr,
f_werks LIKE mard-werks,
f_lgort LIKE mard-lgort,
t_werks LIKE mard-werks,
t_lgort LIKE mard-lgort,
labst type c ,
remark(50) type c,
END OF i_final.
DATA : filename TYPE string,
title type c.
DATA: it_list TYPE STANDARD TABLE OF i_list WITH HEADER LINE,
it_mara TYPE STANDARD TABLE OF i_mara WITH HEADER LINE,
it_marc TYPE STANDARD TABLE OF i_marc WITH HEADER LINE,
it_mard TYPE STANDARD TABLE OF i_mard WITH HEADER LINE,
it_t001l TYPE STANDARD TABLE OF i_t001l WITH HEADER LINE,
it_t024e TYPE STANDARD TABLE OF i_t024e WITH HEADER LINE,
it_mkpf TYPE STANDARD TABLE OF i_mkpf WITH HEADER LINE,
it_final TYPE STANDARD TABLE OF i_final WITH HEADER LINE.
DATA: fs_fldcat TYPE slis_fieldcat_alv , "Structure for Field catalog
it_fldcat LIKE TABLE OF fs_fldcat,
layout TYPE slis_layout_alv,
V_REPID LIKE sy-repid.
DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
EVENTS TYPE SLIS_T_EVENT,
GW_EVENT TYPE SLIS_ALV_EVENT,
GI_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: lv_matnr TYPE mara-matnr,
lv_ekorg TYPE t024e-ekorg.
DATA: BEGIN OF gmhead.
INCLUDE STRUCTURE bapi2017_gm_head_01.
DATA: END OF gmhead.
DATA: BEGIN OF gmcode.
INCLUDE STRUCTURE bapi2017_gm_code.
DATA: END OF gmcode.
DATA: BEGIN OF mthead.
INCLUDE STRUCTURE bapi2017_gm_head_ret.
DATA: END OF mthead.
DATA: BEGIN OF itab OCCURS 100.
INCLUDE STRUCTURE bapi2017_gm_item_create.
DATA: END OF itab.
DATA: BEGIN OF errmsg OCCURS 10.
INCLUDE STRUCTURE bapiret2.
DATA: END OF errmsg.
*data: wmenge like iseg-menge,
errflag.
*Selection Screen Declaration
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001.
PARAMETERS: p_bukrs LIKE t024e-bukrs OBLIGATORY,
ekorg LIKE t024e-ekorg,
f_file LIKE ibipparms-path OBLIGATORY,
xblnr like mkpf-xblnr,
Doc_Post type checkbox.
SELECTION-SCREEN END OF BLOCK blk .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR f_file .
CLEAR f_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = .
DYNPRO_NUMBER = SYST-DYNNR
IMPORTING
file_name = f_file.
START-OF-SELECTION.
filename = f_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
has_field_separator = 'x'
TABLES
data_tab = it_final
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PERFORM validate_data.
PERFORM bapi_goods_mvt.
PERFORM alv_grid_display.
endif.
PERFORM BAPI_GOODS_MVT.
*& Form VALIDATE_DATA
1.Check Material in Table MARC >> Material Plant Validation
If not found, Fill Remarks with 'Material Not Found in Plant'
2.Check Plant is Assigned to POrg in Table T024W >> Plant POrg Validation
If not found, Fill Remarks with 'Invalid POrg for Plant'
3.Check Location for Plant and Location in Table T001L >> Plant SLoc Validation
If not found, Fill Remarks with 'Invalid Storage Location for Plant'
FORM validate_data .
Get POrg for CompanyCode
SELECT SINGLE ekorg INTO lv_ekorg FROM t024e
WHERE bukrs EQ p_bukrs.
LOOP AT it_final.
Check-1
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = it_final-matnr
IMPORTING
output = lv_matnr.
SELECT SINGLE * FROM marc
WHERE matnr = lv_matnr
AND werks = it_final-f_werks.
IF sy-subrc <> 0.
it_final-remark = 'Material Not Found in Plant'.
append it_final .
endif .
SELECT SINGLE * FROM marc
WHERE matnr = lv_matnr
AND werks = it_final-t_werks.
IF sy-subrc <> 0.
it_final-remark = 'Material Not Found in Plant'.
append it_final .
endif.
Check-2
SELECT SINGLE * FROM t024w
WHERE werks = it_final-t_werks
AND ekorg = lv_ekorg.
IF sy-subrc <> 0.
it_final-remark = 'Invalid POrg for Plant'.
append it_final .
Endif.
SELECT SINGLE * FROM t024w
WHERE werks = it_final-f_werks
AND ekorg = lv_ekorg.
IF sy-subrc <> 0.
it_final-remark = 'Invalid POrg for Plant'.
append it_final .
Endif.
Check-3
SELECT SINGLE * FROM t001l
WHERE werks = it_final-t_werks
AND lgort = it_final-t_lgort.
IF sy-subrc <> 0.
it_final-remark = 'Invalid Storage Location for Plant'.
append it_final .
ENDIF.
SELECT SINGLE * FROM t001l
WHERE werks = it_final-f_werks
AND lgort = it_final-f_lgort.
IF sy-subrc <> 0.
it_final-remark = 'Invalid Storage Location for Plant'.
append it_final .
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " VALIDATE_DATA
*& Form ALV_GRID_DISPLAY
text
FORM alv_grid_display.
DATA:l_edit TYPE lvc_s_glay.
PERFORM build_fieldcat.
PERFORM layout_build USING layout.
PERFORM fill_list_header USING gi_listheader.
v_repid = sy-repid.
gw_event-name = slis_ev_top_of_page.
gw_event-form = 'TOP_OF_PAGE'.
APPEND gw_event TO events.
l_edit-edt_cll_cb = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = V_REPID
i_callback_pf_status_set = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
i_grid_title = title
I_GRID_SETTINGS =
is_layout = layout
it_fieldcat = it_fldcat
i_save = 'x'
IS_VARIANT =
IT_EVENTS = events
TABLES
t_outtab = it_final
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.
ENDFORM. "ALV_GRID_DISPLAY
*& Form build_fieldcat
text
FORM build_fieldcat.
PERFORM fieldcat USING: 'IT_FINAL' "Internal table name
'MATNR' "CREDIT CONTROL AREA
'10' "length
'MATERIAL' "Description
'L' "Dictionary long text
' ' "Database table name
' ' "Database tab' field name
' ' "Justification R/M/L
' ' "To do total
' ' "emphasize
' ' "emphasize
' ' "emphasize
' ' "Data type
' ' "edit.
' '. "round
PERFORM fieldcat USING: 'IT_FINAL' "Internal table name
'F_WERKS' "CREDIT CONTROL AREA
'10' "length
'FROM PLANT' "Description
'L' "Dictionary long text
' ' "Database table name
' ' "Database tab' field name
' ' "Justification R/M/L
' ' "To do total
' ' "emphasize
' ' "emphasize
' ' "emphasize
' ' "Data type
' ' "edit.
' '. "round
PERFORM fieldcat USING: 'IT_FINAL' "Internal table name
'F_LGORT' "CREDIT CONTROL AREA
'10' "length
'LOCATION' "Description
'L' "Dictionary long text
' ' "Database table name
' ' "Database tab' field name
' ' "Justification R/M/L
' ' "To do total
' ' "emphasize
' ' "emphasize
' ' "emphasize
' ' "Data type
' ' "edit.
' '. "round
PERFORM fieldcat USING: 'IT_FINAL' "Internal table name
'T_WERKS' "CREDIT CONTROL AREA
'10' "length
'TO PLANT' "Description
'L' "Dictionary long text
' ' "Database table name
' ' "Database tab' field name
' ' "Justification R/M/L
' ' "To do total
' ' "emphasize
' ' "emphasize
' ' "emphasize
' ' "Data type
' ' "edit.
' '. "round
PERFORM fieldcat USING: 'IT_FINAL' "Internal table name
'T_LGORT' "CREDIT CONTROL AREA
'10' "length
'LOCATION' "Description
'L' "Dictionary long text
' ' "Database table name
' ' "Database tab' field name
' ' "Justification R/M/L
' ' "To do total
' ' "emphasize
' ' "emphasize
' ' "emphasize
' ' "Data type
' ' "edit.
' '. "round
PERFORM fieldcat USING: 'I_FINAL' "Internal table name
'LABST' "CREDIT CONTROL AREA
'10' "length
'QUANTITY' "Description
'L' "Dictionary long text
' ' "Database table name
' ' "Database tab' field name
' ' "Justification R/M/L
' ' "To do total
' ' "emphasize
' ' "emphasize
' ' "emphasize
' ' "Data type
' ' "edit.
' '. "round
PERFORM fieldcat USING: 'I_FINAL' "Internal table name
'REMARK' "CREDIT CONTROL AREA
'50' "length
'REMARK' "Description
'L' "Dictionary long text
' ' "Database table name
' ' "Database tab' field name
' ' "Justification R/M/L
' ' "To do total
' ' "emphasize
' ' "emphasize
' ' "emphasize
' ' "Data type
' ' "edit.
' '. "round
ENDFORM. "build_fieldcat
*& Form fieldcat
text
FORM fieldcat CHANGING value(p_tname)
value(p_fname)
value(p_length)
value(p_ltext)
value(p_typet)
value(p_rtab)
value(p_rfield)
value(p_just)
value(p_dosum)
value(p_emphasize)
value(p_datatype)
value(p_no_zero)
value(p_hotspot)
value(p_edit)
value(p_round).
fs_fldcat-tabname = p_tname.
fs_fldcat-fieldname = p_fname.
fs_fldcat-outputlen = p_length.
fs_fldcat-seltext_l = p_ltext.
fs_fldcat-input = p_typet.
fs_fldcat-edit = p_rtab.
fs_fldcat-ref_fieldname = p_rfield.
fs_fldcat-just = p_just.
fs_fldcat-do_sum = p_dosum.
fs_fldcat-emphasize = p_emphasize.
fs_fldcat-datatype = p_datatype.
fs_fldcat-lzero = p_no_zero.
fs_fldcat-hotspot = p_hotspot.
fs_fldcat-edit = p_edit.
fs_fldcat-decimals_out = p_round.
APPEND fs_fldcat TO it_fldcat.
ENDFORM. "fieldcat
*& Form fill_list_header
text
-->FV_I_LISTHEADER text
FORM fill_list_header USING fv_i_listheader TYPE slis_t_listheader.
DATA: lw_line TYPE slis_listheader,
l_date(10),
l_time(10).
DATA : p_date LIKE sy-datum.
DATA : p_time LIKE sy-uzeit.
DATA : ztext(17).
DATA : ztext1(80).
p_date = sy-datum.
p_time = sy-uzeit.
CLEAR fv_i_listheader.
CONCATENATE p_date6(2) '.' p_date4(2) '.' p_date+0(4) INTO l_date.
CONCATENATE p_time0(2) ':' p_time2(2) ':' p_time+4(2) INTO l_time.
IF doc_post = 'X'.
ztext = 'Execute Mode'.
ELSE.
ztext = 'Update Mode'.
ENDIF.
CLEAR lw_line.
lw_line-typ = 'H'.
lw_line-info = sy-repid.
APPEND lw_line TO fv_i_listheader.
CLEAR lw_line.
lw_line-typ = 'H'.
lw_line-info = l_date.
APPEND lw_line TO fv_i_listheader.
CLEAR lw_line.
lw_line-typ = 'H'.
lw_line-info = l_time.
APPEND lw_line TO fv_i_listheader.
CLEAR lw_line.
lw_line-typ = 'H'.
lw_line-info = sy-uname.
APPEND lw_line TO fv_i_listheader.
CLEAR lw_line.
lw_line-typ = 'H'.
lw_line-info = ztext.
APPEND lw_line TO fv_i_listheader.
endform. "fill_list_header
*& Form top_of_page
text
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gi_listheader.
ENDFORM. "top_of_page
*& Form layout_build
text
-->LAYOUT text
FORM layout_build USING layout TYPE slis_layout_alv.
layout-box_fieldname = 'BOX'.
layout-zebra = 'X'. " STRIPED PATTERN
layout-numc_sum = 'X'. " TOTALS FOR NUMC-FIELDS
layout-no_keyfix = ' '. " DO NOT FIX KEYCOLUMNS
layout-colwidth_optimize = ' ' .
layout-flexible_key = ' '. " KEY COLUMNS MOVABLE,...
layout-detail_popup = ' '. " SHOW DETAIL IN POPUP
ENDFORM. "layout_build
*& Form BAPI_GOODS_MVT
text
FORM bapi_goods_mvt.
DATA: dc_numner TYPE bapi2017_gm_head_ret-mat_doc,
dc_year TYPE bapi2017_gm_head_ret-doc_year.
clear: dc_numner, dc_year.
if doc_post = 'X'.
gmhead-pstng_date = sy-datum.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
gmhead-REF_DOC_NO = it_mkpf-xblnr.
gmcode-gm_code = '04'. "04 - MB1B - Transfer Posting
LOOP AT it_final.
itab-move_type = '301'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = it_final-matnr
IMPORTING
output = itab-material.
itab-plant = it_final-f_werks .
itab-stge_loc = it_final-f_lgort .
itab-MOVE_PLANT = it_final-t_werks .
itab-move_stloc = it_final-t_lgort .
itab-entry_qnt = it_final-labst .
APPEND itab.
ENDLOOP.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = gmhead
goodsmvt_code = gmcode
TESTRUN = ' '
IMPORTING
goodsmvt_headret = mthead
materialdocument = dc_numner
matdocumentyear = dc_year
TABLES
goodsmvt_item = itab
GOODSMVT_SERIALNUMBER =
return = errmsg.
IF errmsg[] IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
LOOP AT it_final.
it_final-remark = dc_numner.
MODIFY it_final.
ENDLOOP.
endif.
ELSE.
clear errflag.
LOOP AT errmsg.
IF errmsg-type EQ 'E'.
WRITE:/'Error in function', errmsg-message.
errflag = 'X'.
ELSE.
WRITE:/ errmsg-message.
ENDIF.
ENDLOOP.
endif.
ENDFORM. "BAPI_GOODS_MVT -
F4 help for Date field and Validation
Hi Friends,
I am new to BSP programming .I knew getting F4 help in normal ABAP.But i don't know in BSP .
I want simple steps to get F4 for a field on Page as well as date field .
and How to valid those entered dates.
Presently i am using length 10 character variable for DATE without F4 help and No validation.
I think you guys will help me out.
Thanks,
Venkat.OWelcome to SDN.
for F4 help with validation for dates you can use the following code.
<htmlb:inputField id = "wf_ad_date"
type = "date"
showHelp = "TRUE"
value = "<%= sy-datum %>"
visible = "true"
disabled = "false"
required = "true"
maxlength = "10"
size = "10"
doValidate = "true"
design = "standard" />
For other type of fields check out this weblog by Thomas Jung
<a href="/people/thomas.jung3/blog/2005/08/22/bsp-value-input-help-popups-version-30 Value Input Help Popups Version 3.0</a>
Regards
Raja -
Hi all,
I am doing FI validation in SRM 4.0.Actually i am getting error based on the GL account and company code at line item which are based on the costcenter or internal order or WBS using...for this i am using FM BAPI_ACC_GL_POSTING_CHECK(RFC enabled) from R3 to SRM.the error message i am getting i was populating while creating SC/PO in the DOC_CHECK_BADI ..One strange thing is for testing i have commented the code in DOC_CHECK_BADI still i am getting the error based on GL account and company code ..firstly i thought i might be some other error but this is the same error i am getting from the BAPI_ACC_GL_POSTING_CHECK..
I want to know is there any standard functionality that the error is coming from the backend or it is the code that i have written
Thank you<b>BADI CODE IN DOC_CHECK_BADI FOR POS</b>
For direct PO's, R/3 validation. Get PO details
Data: WA_HEADER TYPE BBP_PDS_PO_HEADER_D,
LT_ITEMDATA TYPE TABLE OF BBP_PDS_PO_ITEM_D,
WA_ITEMDATA LIKE LINE OF LT_ITEMDATA,
LT_ACC TYPE TABLE OF BBP_PDS_ACC,
WA_ACC LIKE LINE OF LT_ACC,
lt_bapiache08 type zbapiache08,
lt_bapiacgl08 type table of ZBAPIACGL08,
wa_bapiacgl08 type ZBAPIACGL08,
lt_bapiaccr08 type table of ZBAPIACCR08,
wa_bapiaccr08 type ZBAPIACCR08,
lt_return type table of BAPIRET2,
wa_return type BAPIRET2,
wa_messages type BBP_SMESSAGES_BADI,
lv_docdate(8),
lv_pstngdate(8),
lv_counter type i,
lv_value(15),
lv_amount(16),
lv_len type i,
LV_SYSID(9).
UPDK900880
DATA : LV_PROFIT_CTR(4).
UPDK900880
get purchase order details
IF SY-UCOMM = 'SAVE' AND SY-TCODE = 'BBP_POC'.
*IF SY-UCOMM = 'CHEC' AND SY-TCODE = 'BBP_POC'.
CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
EXPORTING
I_GUID = IV_DOC_GUID
I_OBJECT_ID =
I_WITH_ITEMDATA = 'X'
IMPORTING
E_HEADER = WA_HEADER
TABLES
E_ITEM = LT_ITEMDATA
E_ACCOUNT = LT_ACC
UPDK900880
LOOP AT LT_ACC INTO WA_ACC.
MOVE WA_ACC-PROFIT_CTR+0(4) TO LV_PROFIT_CTR.
ENDLOOP.
UPDK900880
Concatenate document date and posting date, default system date
concatenate sy-datum0(4) sy-datum4(2) sy-datum+6(2) into lv_docdate.
concatenate sy-datum0(4) sy-datum4(2) sy-datum+6(2) into lv_pstngdate.
build structure bapiache08 of RFC BAPI_ACC_GL_POSTING_CHECK
UPDK900880
move: LV_PROFIT_CTR TO lt_bapiache08-comp_code,
wa_header-co_code to lt_bapiache08-comp_code,
UPDK900880
'BTUSER' to lt_bapiache08-username,
sy-datum+0(4) to lt_bapiache08-fisc_year,
lv_docdate to lt_bapiache08-doc_date,
lv_pstngdate to lt_bapiache08-pstng_date,
'SA' to lt_bapiache08-doc_type.
build structure bapiacgl08 of RFC BAPI_ACC_GL_POSTING_CHECK
loop at lt_acc into wa_acc.
lv_counter = lv_counter + 1.
move: lv_counter to wa_bapiacgl08-itemno_acc,
wa_acc-g_l_acct to wa_bapiacgl08-gl_account,
UPDK900880
wa_header-co_code to wa_bapiacgl08-comp_code,
LV_PROFIT_CTR TO wa_bapiacgl08-comp_code,
UPDK900880
lv_pstngdate to wa_bapiacgl08-pstng_date,
'SA' to wa_bapiacgl08-doc_type,
sy-datum+0(4) to wa_bapiacgl08-fisc_year.
if wa_acc-cost_ctr is not initial.
move wa_acc-cost_ctr to wa_bapiacgl08-costcenter.
elseif wa_acc-wbs_elem_e is not initial.
move wa_acc-wbs_elem_e to wa_bapiacgl08-wbs_element.
elseif wa_acc-order_no is not initial.
move wa_acc-order_no to wa_bapiacgl08-orderid.
endif.
append wa_bapiacgl08 to lt_bapiacgl08.
clear wa_bapiacgl08.
lv_counter = lv_counter + 1.
move: lv_counter to wa_bapiacgl08-itemno_acc,
UPDK900880
wa_header-co_code to wa_bapiacgl08-comp_code,
LV_PROFIT_CTR TO wa_bapiacgl08-comp_code,
UPDK900880
'0014109889' to wa_bapiacgl08-gl_account,
lv_pstngdate to wa_bapiacgl08-pstng_date,
'SA' to wa_bapiacgl08-doc_type,
sy-datum+0(4) to wa_bapiacgl08-fisc_year.
append wa_bapiacgl08 to lt_bapiacgl08.
clear wa_bapiacgl08.
endloop.
clear lv_counter.
build structure bapiaccr08 of RFC BAPI_ACC_GL_POSTING_CHECK
loop at lt_itemdata into wa_itemdata.
lv_counter = lv_counter + 1.
move: lv_counter to wa_bapiaccr08-itemno_acc,
wa_itemdata-value to wa_bapiaccr08-amt_doccur,
'USD' to wa_bapiaccr08-currency.
append wa_bapiaccr08 to lt_bapiaccr08.
clear wa_bapiaccr08.
lv_counter = lv_counter + 1.
move wa_itemdata-value to lv_value.
concatenate lv_value '-' into lv_amount.
move: lv_counter to wa_bapiaccr08-itemno_acc,
lv_amount to wa_bapiaccr08-amt_doccur,
'USD' to wa_bapiaccr08-currency.
append wa_bapiaccr08 to lt_bapiaccr08.
clear wa_bapiaccr08.
endloop.
clear lv_counter.
Check the SRM system
IF SY-SYSID = 'UPD'. "3
LV_SYSID = 'UHD_111'.
CONDENSE LV_SYSID NO-GAPS.
ELSEIF SY-SYSID = 'UPX'. "3
LV_SYSID = 'SAPUHD111'.
CONDENSE LV_SYSID NO-GAPS.
ELSEIF SY-SYSID = 'UPQ'. "3
LV_SYSID = 'SAPUHQ100'.
CONDENSE LV_SYSID NO-GAPS.
ELSEIF SY-SYSID = 'UPP'. "3
LV_SYSID = 'SAPUHP100'.
CONDENSE LV_SYSID NO-GAPS.
ENDIF.
RFC call
Call Function 'BAPI_ACC_GL_POSTING_CHECK' destination LV_SYSID
Exporting
DOCUMENTHEADER = lt_bapiache08
Tables
ACCOUNTGL = lt_bapiacgl08
CURRENCYAMOUNT = lt_bapiaccr08
RETURN = lt_return.
Loop at lt_return into wa_return.
lv_len = strlen( wa_return-message ).
if lv_len le 49.
move: wa_return to wa_messages-msgty,
'BBP_PD' to wa_messages-msgid,
'047' to wa_messages-msgno,
wa_return-message to wa_messages-msgv1.
append wa_messages to et_messages.
elseif lv_len gt 50 and lv_len le 99.
move: wa_return to wa_messages-msgty,
'BBP_PD' to wa_messages-msgid,
'047' to wa_messages-msgno,
wa_return-message+0(49) to wa_messages-msgv1,
wa_return-message+50(49) to wa_messages-msgv2.
append wa_messages to et_messages.
elseif lv_len ge 100 and lv_len le 149.
move: wa_return to wa_messages-msgty,
'BBP_PD' to wa_messages-msgid,
'047' to wa_messages-msgno,
wa_return-message+0(49) to wa_messages-msgv1,
wa_return-message+50(49) to wa_messages-msgv2,
wa_return-message+100(49) to wa_messages-msgv3.
append wa_messages to et_messages.
elseif lv_len ge 150 and lv_len le 199.
move: wa_return to wa_messages-msgty,
'BBP_PD' to wa_messages-msgid,
'047' to wa_messages-msgno,
wa_return-message+0(49) to wa_messages-msgv1,
wa_return-message+50(49) to wa_messages-msgv2,
wa_return-message+100(49) to wa_messages-msgv3,
wa_return-message+150(49) to wa_messages-msgv4.
append wa_messages to et_messages.
endif.
clear: wa_messages, wa_return.
endloop.
endif.
<b>BADI CODE FOR DOC_CHECK_BADI FOR SCs</b>
*---Declaration
Data: WA_HEADER TYPE BBP_PDS_SC_HEADER_D,
LT_ITEMDATA TYPE TABLE OF BBP_PDS_SC_ITEM_D,
WA_ITEMDATA LIKE LINE OF LT_ITEMDATA,
LT_ACC TYPE TABLE OF BBP_PDS_ACC,
WA_ACC LIKE LINE OF LT_ACC,
lt_bapiache08 type zbapiache08,
lt_bapiacgl08 type table of ZBAPIACGL08,
wa_bapiacgl08 type ZBAPIACGL08,
lt_bapiaccr08 type table of ZBAPIACCR08,
wa_bapiaccr08 type ZBAPIACCR08,
lt_return type table of BAPIRET2,
wa_return type BAPIRET2,
wa_messages type BBP_SMESSAGES_BADI,
lv_docdate(8),
lv_pstngdate(8),
lv_counter type i,
lv_value(15),
lv_amount(16),
lv_len type i,
LV_SYSID(9).
*------Changes for Line item company code
DATA : LV_PROFIT_CTR(4).
Get SC Details
IF ( SY-UCOMM = 'SC_CHECK' AND SY-TCODE = 'BBPSC03' ) OR ( SY-UCOMM = 'SC_ORDER' AND SY-TCODE = 'BBPSC03' ).
CALL FUNCTION 'BBP_PD_SC_GETDETAIL'
EXPORTING
I_GUID = IV_DOC_GUID
I_OBJECT_ID =
I_WITH_ITEMDATA = 'X'
IMPORTING
E_HEADER = WA_HEADER
TABLES
E_ITEM = LT_ITEMDATA
E_ACCOUNT = LT_ACC
Concatenate document date and posting date, default system date
concatenate sy-datum6(2) sy-datum0(4) sy-datum+4(2) into lv_docdate.
concatenate sy-datum6(2) sy-datum0(4) sy-datum+4(2) into lv_pstngdate.
concatenate sy-datum0(4) sy-datum4(2) sy-datum+6(2) into lv_docdate.
concatenate sy-datum0(4) sy-datum4(2) sy-datum+6(2) into lv_pstngdate.
build structure bapiache08 of RFC BAPI_ACC_GL_POSTING_CHECK
*loop at LT_ITEMDATA into wa_ITEMDATA.
move wa_itemdata-BE_CO_CODE to lt_bapiache08-comp_code.
*endloop.
LOOP AT LT_ACC INTO WA_ACC.
MOVE WA_ACC-PROFIT_CTR+0(4) TO LV_PROFIT_CTR.
ENDLOOP.
Chnages for Line item company code
move: LV_PROFIT_CTR TO lt_bapiache08-comp_code,
wa_header-co_code to lt_bapiache08-comp_code,
End of Chnages for Line item company code
'BTUSER' to lt_bapiache08-username,
sy-datum+0(4) to lt_bapiache08-fisc_year,
lv_docdate to lt_bapiache08-doc_date,
lv_pstngdate to lt_bapiache08-pstng_date,
'SA' to lt_bapiache08-doc_type.
build structure bapiacgl08 of RFC BAPI_ACC_GL_POSTING_CHECK
loop at lt_acc into wa_acc.
lv_counter = lv_counter + 1.
move: lv_counter to wa_bapiacgl08-itemno_acc,
wa_acc-g_l_acct to wa_bapiacgl08-gl_account,
Chnages for Line item company code
wa_header-co_code to wa_bapiacgl08-comp_code,
LV_PROFIT_CTR TO wa_bapiacgl08-comp_code,
End of Chnages for Line item company code
lv_pstngdate to wa_bapiacgl08-pstng_date,
'SA' to wa_bapiacgl08-doc_type,
sy-datum+0(4) to wa_bapiacgl08-fisc_year.
if wa_acc-cost_ctr is not initial.
move wa_acc-cost_ctr to wa_bapiacgl08-costcenter.
elseif wa_acc-wbs_elem_e is not initial.
move wa_acc-wbs_elem_e to wa_bapiacgl08-wbs_element.
elseif wa_acc-order_no is not initial.
move wa_acc-order_no to wa_bapiacgl08-orderid.
endif.
append wa_bapiacgl08 to lt_bapiacgl08.
clear wa_bapiacgl08.
lv_counter = lv_counter + 1.
move: lv_counter to wa_bapiacgl08-itemno_acc,
Chnages for Line item company code
wa_header-co_code to wa_bapiacgl08-comp_code,
LV_PROFIT_CTR TO wa_bapiacgl08-comp_code,
End of Chnages for Line item company code
'0014109889' to wa_bapiacgl08-gl_account,
lv_pstngdate to wa_bapiacgl08-pstng_date,
'SA' to wa_bapiacgl08-doc_type,
sy-datum+0(4) to wa_bapiacgl08-fisc_year.
append wa_bapiacgl08 to lt_bapiacgl08.
clear wa_bapiacgl08.
endloop.
clear lv_counter.
build structure bapiaccr08 of RFC BAPI_ACC_GL_POSTING_CHECK
loop at lt_itemdata into wa_itemdata.
lv_counter = lv_counter + 1.
move: lv_counter to wa_bapiaccr08-itemno_acc,
wa_itemdata-value to wa_bapiaccr08-amt_doccur,
'USD' to wa_bapiaccr08-currency.
append wa_bapiaccr08 to lt_bapiaccr08.
clear wa_bapiaccr08.
lv_counter = lv_counter + 1.
move wa_itemdata-value to lv_value.
concatenate lv_value '-' into lv_amount.
move: lv_counter to wa_bapiaccr08-itemno_acc,
lv_amount to wa_bapiaccr08-amt_doccur,
'USD' to wa_bapiaccr08-currency.
append wa_bapiaccr08 to lt_bapiaccr08.
clear wa_bapiaccr08.
endloop.
clear lv_counter.
Check the SRM system
IF SY-SYSID = 'UPD'. "3
LV_SYSID = 'UHD_111'.
CONDENSE LV_SYSID NO-GAPS.
ELSEIF SY-SYSID = 'UPX'. "3
LV_SYSID = 'SAPUHD111'.
CONDENSE LV_SYSID NO-GAPS.
ELSEIF SY-SYSID = 'UPQ'. "3
LV_SYSID = 'SAPUHQ100'.
CONDENSE LV_SYSID NO-GAPS.
ELSEIF SY-SYSID = 'UPP'. "3
LV_SYSID = 'SAPUHP100'.
CONDENSE LV_SYSID NO-GAPS.
ENDIF.
RFC call
Call Function 'BAPI_ACC_GL_POSTING_CHECK' destination LV_SYSID
Exporting
DOCUMENTHEADER = lt_bapiache08
Tables
ACCOUNTGL = lt_bapiacgl08
CURRENCYAMOUNT = lt_bapiaccr08
RETURN = lt_return.
break-point.
Loop at lt_return into wa_return.
lv_len = strlen( wa_return-message ).
if lv_len le 49.
move: wa_return to wa_messages-msgty,
'BBP_PD' to wa_messages-msgid,
'047' to wa_messages-msgno,
wa_return-message to wa_messages-msgv1.
append wa_messages to et_messages.
elseif lv_len gt 50 and lv_len le 99.
move: wa_return to wa_messages-msgty,
'BBP_PD' to wa_messages-msgid,
'047' to wa_messages-msgno,
wa_return-message+0(49) to wa_messages-msgv1,
wa_return-message+50(49) to wa_messages-msgv2.
append wa_messages to et_messages.
elseif lv_len ge 100 and lv_len le 149.
move: wa_return to wa_messages-msgty,
'BBP_PD' to wa_messages-msgid,
'047' to wa_messages-msgno,
wa_return-message+0(49) to wa_messages-msgv1,
wa_return-message+50(49) to wa_messages-msgv2,
wa_return-message+100(49) to wa_messages-msgv3.
append wa_messages to et_messages.
elseif lv_len ge 150 and lv_len le 199.
move: wa_return to wa_messages-msgty,
'BBP_PD' to wa_messages-msgid,
'047' to wa_messages-msgno,
wa_return-message+0(49) to wa_messages-msgv1,
wa_return-message+50(49) to wa_messages-msgv2,
wa_return-message+100(49) to wa_messages-msgv3,
wa_return-message+150(49) to wa_messages-msgv4.
append wa_messages to et_messages.
endif.
clear: wa_messages, wa_return.
endloop.
endif.
This is what i wrote in BADI except this i wrote nothing ...and no where -
Hi!
I get the message "Enter a valid date ".
Whats wrong ?
Can u please help. Or do you know another FM
for such purposes ?
I must be able to populate various date formats
e.g 04/24/2007, 04-24-2007 .....
Regards
sas
data s type sy-datum.
*04/24/2007
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = '04/24/2007'
IMPORTING
DATE_INTERNAL = s
write s.Hi Erdam,
Go through this simple code, i have not used any function module for date conversion.
PARAMETERS:
p_date(10) TYPE c.
DATA w_date(8) TYPE c.
w_date0(4) = p_date6(4).
IF p_date0(2) > 12 OR p_date3(2) LE 12.
w_date4(2) = p_date3(2).
w_date6(2) = p_date0(2).
ELSEIF p_date0(2) LE 12 OR p_date3(2) > 12.
w_date4(2) = p_date0(2).
w_date6(2) = p_date3(2).
ENDIF.
WRITE w_date.
best regards
Anup. -
Validations at selection-screen
hi ,
how to do validations at selection-screen?
with regards
always learner
points will be rewarded if usefulHi Buddy
Its good to learn alwasys . Here are some progarms which are useful in selection- screen.
Dont forget to reward points.
at selection-screen.
select LIFNR
from LFB1
into table
where lifnr in s_lifnr.
if sy-subrc ne 0.
message e888(sabapdocu) with 'no number found'.
endif.
in this way u can write the select query.
selection-screen begin of block b1.
parameters: p_datum1 type sy-datum,
p_datum2 type sy-datum.
selection-screen end of block b1.
at selection-screen on block b1.
if p_datum1 is initial
and p_datum2 is initial.
message e001(00) with 'Enter at least one date'.
endif.
PARAMETERS: TEST1(10) MODIF ID SC1,
TEST2(10) MODIF ID SC2,
TEST3(10) MODIF ID SC1,
TEST4(10) MODIF ID SC2.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'SC1'.
SCREEN-INTENSIFIED = '1'.
MODIFY SCREEN.
CONTINUE.
ENDIF.
IF SCREEN-GROUP1 = 'SC2'.
SCREEN-INTENSIFIED = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: R1 RADIOBUTTON GROUP RAD1 DEFAULT 'X',
R2 RADIOBUTTON GROUP RAD1,
R3 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME.
PARAMETERS: R4 RADIOBUTTON GROUP RAD2 DEFAULT 'X',
R5 RADIOBUTTON GROUP RAD2,
R6 RADIOBUTTON GROUP RAD2.
SELECTION-SCREEN END OF BLOCK B2.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP RAD1.
IF R1 = 'X'.
MESSAGE W040(HB).
ENDIF.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP RAD2.
IF R4 = 'X'.
MESSAGE W040(HB).
ENDIF.
Maybe you are looking for
-
How to get current value of SEQUENCE without using NEXTVAL
Hi, Here is my requirement. I need to provide a screen for allowing user to change the sequence # at any given instance. If I use CURRVAL, i get error 'ORA-08002 sequence EMP_NO.CURRVAL is not yet defined in this session' If I use NEXTVAL and then CU
-
How do I get my money back?
I used this product for one project back in September, and haven't touched it in months. I've been getting charged $15.89 a month since, and had no idea I signed up for this. I don't want the product, and now I'm out $45 dollars to something I don't
-
Slicing image on different angle and exporting to Dreamweaver ?
Hi! I think I searched entire web and didn't find the answer.. Is it possible to slice image on different angle not just rectangle ? On images below you can see the section that I'm trying to make a slice and slowly I'm loosing hope because I think I
-
I'm building an application in windows forms and have the way to publish it into an ftp folder at a Linux server on the internet where I have a web hosting account. I set up the application to update from a specific url. after publishing VS2010 keeps
-
Help Please: Slow To Restart After Update
My family member got his Macbook in August 2006 but rarely if ever did any updates. I ran Software Update today and there were a lot of things listed so I decided to do it in steps. First, there were a couple of firmware updates which downloaded then