You are on page 1of 22

2/9/2015

DocumentDisplay

GettingGMEAPIstoWorkUsingVisionDatabaseExamplesFromOracleSupport(DocID
380457.1)

GettingGMEAPIstoWorkUsingVisionDatabase
Examples
***Checkedforrelevanceon11JAN2013***
Product:ProcessExecution(GME)APIsMinimumVersion:11.5.10CU2

AnOracleWhitePaper
Abstract
ThispapershowsseveralsimpletestscriptsthatexecutemanyofthepublicGMEAPIs.Thebasisofall
ofthesescriptshasbeentheVisiondatabase.Allofthescriptsdetailedbelowhavebeenproventorun
successfullyusingourowninternalVisioninstallusingApplicationsVersion11.5.10CU2.
Youwillnoticethatthescriptsarequitesimpleandhavebeenwrittenprincipallytotestwhetherornot
theAPIsfunctionasdesigned.MostofthemhavebeenwrittenbyOracleApplicationsSupportwhen
questionshavebeenraisedastowhethertheAPIsareindeedworkingastheyshould
Youshouldbeabletotaketheexampleslistedbelowandwiththenecessarychanges(thatis,changing
constantssuchasItemId,UOM,documentortransactionid)getthescriptstoworkonyourown
systems.Remarksareaddedaftereachscriptaswhatchangesshouldbemadeinordertogetthe
API(s)calledbythescripttoworkforyourowncircumstances.
IfyouarehavingproblemsgettingthecorrectresultsfromanAPI,youshouldfirstofalltryusingtheon
lineapplicationtorecreatewhatyouaretryingtoachieveintheAPI.Forexample,ifyouareusingthe
applicationtocreateaBatchusingaparticularRecipe,thenyoushouldbeabletoachievethesame
resultwhenusingtheAPI.ThisisbecausetheunderlyingcodeusedbyboththeapplicationandtheAPI
isessentiallythesame.
ItisworthwhilecommentinghereastothelimitsofsupportthatOracleSupportServicescanprovide
regardingtheuseofthepubliclyprovidedAPIs.
OracleSupportServiceswillsupportAPIsinthattheywillensurethattheyfunctionasdesignedandthat
thedatainsertedbytheAPIsintothedatabaseiscorrect.ItisNOTthefunctionofsupporttoprovide
helptotheuseronwritingtheirowncustomwrapperfilesbuttheymaybeabletogiveyoutheadviceon
this.AnexamplewrapperfileisprovidedintheUserGuide(seebelow).
Asageneralcomment,whenauserissettingouttowriteproceduresandfunctionsusingtheseAPIs,it
isadvisablefirsttowritesimplescriptsliketheonesdetailedinthispaper(thatistosay,withasingle
rowofdataembeddedinthescriptasconstants)tobecomeconfidentoftheworkingoftheAPIitself
beforemovingontoawrapperwhichreadsandprocessesabatchofinputrows.
ItshouldalsobenotedthatOraclewillsupporttheuseofthePublicAPIsONLY.Youshouldnotdirectly
calltheprivateAPIs.Forexample,theuseof'gme_api_pub.create_batch'issupported,however,
'gme_api_main.create_batch'isnotsupported.
AnadditionalpointtoisthatGMEDebuggingworkswhenusingtheAPIsintheexactlythesamewaythat
itworkswhenusingtheapplicationinthenormalway.
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

1/22

2/9/2015

DocumentDisplay

ThiscanprovideusefuladditionalinformationiftheresultsofanAPIrunarenotasexpected.
InordertogenerateaGMEdebugfile,dothefollowing:
1. SetProfileOption'FND:DebugLogEnabled'atUserlevelto'Yes'andProfileOption'FND:Debug
LogLevel'atUserlevelto'Statement'andruntheAPIinthenormalway.
2. TheGMEDebuglogfilesaretobefoundinthe'utl_file_dir'directory.Thisquery
selectnvl(substr(value,1,instr(value,',')1),value)
fromv$parameter
wherename='utl_file_dir'
/
willshowtheuserthedirectorywherethelogfilewillbegenerated.GMEdebugLogfilenamesstart
withtheApplicationsUserName,andtheformatofthefilenameis'USERNAMEEvent'forexample
ORAUSRCreateBatchorORAUSRAllocateLine.
ForadetaileddescriptionofavailablepublicAPIs,refertotheProcessExecutionAPIUsersGuide
Release11iPartNo.A9738804.WhenattemptingtouseanAPI,itisrecommendedtoreadthe
manualthoroughly,especiallythesectionsthatoutlinetheparametersrequiredbytherelevantAPI.
AllofthescriptsprovidedinthisdocumentshouldbeexecutedusingtheAPPSSQL*Plususer.

DocumentHistory
CreateDate:25JUL2006
LastUpdateDate:01AUG2006

TableofContents
Example1:CreationofbatchusingtheRECIPEcreationmode
Example2:CreationofbatchbyProduct
Example3:CreationusingOutputQuantity
Example4:Create,ReleaseandSaveBatch
Example5:Createabatchandinsertanadditionalmaterialline
Example6:Insert_line_allocationAPI
Example7:Close(Complete)Batch
Example8:Release,RecordUsageandCompleteStep
RelatedDocuments

Example1:CreationofbatchusingtheRECIPEcreationmode
altersessionsetnls_language=american
setserveroutputonsize1000000
DECLARE
p_api_versionNUMBERDEFAULTgme_api_pub.api_version
p_validation_levelNUMBERDEFAULTgme_api_pub.max_errors
p_init_msg_listBOOLEANDEFAULTFALSE
P_batch_typeNUMBERDEFAULT0
p_orgn_codeVARCHAR2(4)DEFAULT'PR1'
x_batch_headergme_batch_header%ROWTYPE
x_unallocated_materialgme_api_pub.unallocated_materials_tab
x_message_countNUMBER
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

2/22

2/9/2015

DocumentDisplay

x_message_listVARCHAR2(100)
x_return_statusVARCHAR2(1)
l_batch_headerGME_BATCH_HEADER%ROWTYPE
l_msg_index_outNUMBER
BEGIN
l_batch_header.plant_code:='PR1'
l_batch_header.batch_type:=p_batch_type
l_batch_header.batch_no:=''
l_batch_header.plan_start_date:=''
l_batch_header.plan_cmplt_date:=''
l_batch_header.due_date:=TO_DATE('10AUG200612:00:00','DDMONYYYYHH24:MI:SS')
l_batch_header.update_inventory_ind:='Y'
l_batch_header.recipe_validity_rule_id:=1239
l_batch_header.wip_whse_code:='PR1'
fnd_global.apps_initialize(user_id=>1003637,
resp_id=>null,
resp_appl_id=>null)
gme_api_pub.create_batch(
p_api_version=>p_api_version
,p_validation_level=>p_validation_level
,p_init_msg_list=>p_init_msg_list
,p_commit=>true
,x_message_count=>x_message_count
,x_message_list=>x_message_list
,x_return_status=>x_return_status
,p_batch_header=>l_batch_header
,x_batch_header=>x_batch_header
,p_batch_size=>10
,p_batch_size_uom=>'KG'
,p_creation_mode=>'RECIPE'
,p_recipe_id=>null
,p_recipe_no=>'JGC_1'
,p_recipe_version=>'301'
,p_product_no=>null
,p_product_id=>null
,p_ignore_qty_below_cap=>true
,p_ignore_shortages=>true
,x_unallocated_material=>x_unallocated_material)
gme_debug.display_messages(x_message_count)
dbms_output.put_line('x_message_count='||TO_CHAR(x_message_count))
dbms_output.put_line('x_message_list=
'||length(x_message_list)||SubStr(x_message_list,length(x_message_list)20,20))
dbms_output.put_line('x_message_list='||x_message_list)
dbms_output.put_line('x_return_status='||x_return_status)
dbms_output.put_line('x_batch_header.batch_id='||TO_CHAR(x_batch_header.batch_id))
dbms_output.put_line(SubStr('x_batch_header.plant_code='||x_batch_header.plant_code,1,255))
dbms_output.put_line(SubStr('x_batch_header.batch_no='||x_batch_header.batch_no,1,255))
END
/
TofindtheValidityRuleId,runthisscript
selectr.recipe_no
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

3/22

2/9/2015

DocumentDisplay

,r.recipe_version
,r.recipe_id
,v.RECIPE_VALIDITY_RULE_ID
,v.orgn_code
,RECIPE_USE
,PREFERENCe
,START_DATe
,END_DATE
,MIN_QTY
,MAX_QTY
,STD_QTY
,ITEM_UM
fromgmd_recipesr
,gmd_recipe_validity_rulesv
wherer.recipe_no='&recipe_no'
andr.recipe_version='&version'
andr.recipe_id=v.recipe_id
orderby
v.preference

RemarksonExample1
1. Noticethealtersessionsetnls_language=americancommand.Thiscommandisusedtoensurethatthe
languageinthecurrentSQL*PlussessionmatchesoneoftheinstalledlanguageswithintheApplication.Itis
alwayssafetosetthistoamerican.
2. Thesetserveroutputonsize1000000commandistheretoensurethatthe'dbms_out.put_line'messagescan
beseenonthescreen.Inreallifeexamples,theuserwillprobablyusethe'utl_file.put_line'commandinorder
towritethesemessagestoatextlogfile.
3. NotethecombinationoftheRecipeNumberandVersionandtheValidityRuleId.TheValidityRuleIdmustbe
attachedtotherelevantRecipe,andbothmustbeApprovedforGeneralUse.TheValidityRulemustbe
effectiveontherelevantbatchdates(inthiscase,thebatchduedate).TofindtheappropriatevalueofValidity
RuleId,runthescriptshownabove.
4. NotetheBatchSizeandUOM.ThesemustbevalidwithinthelimitssetbytheValidityRulebeingused.
5. Thefnd_global.apps_initializeisusedtosettheapplicationcontext.Intheaboveexample,thecontextisset
accordingtotheapplicationsuserwhoseidis1003637.Therelevantidcanfoundfortherequireduserbyusing
thiscommand:selectuser_idfromfnd_userwhereuser_name='&user_name'andenteringtherequired
username.Theuserselectedshouldhavearesponsibilityattachedwhichallowscreationofbatchesviathe
application.
6. AfulldescriptionoftheCreateBatchAPIanditsparameterscanbefoundintheUserGuidepages416to4
19.

Example2:CreationofbatchbyProduct
setserveroutputonsize1000000
altersessionsetnls_language=american
DECLARE
x_message_countNUMBER
x_message_listVARCHAR2(2000)
x_return_statusVARCHAR2(1)
p_batch_headerGME_BATCH_HEADER%rowtype
x_batch_headerGME_BATCH_HEADER%rowtype
x_unallocated_materialGME_API_PUB.UNALLOCATED_MATERIALS_TAB
BEGIN
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

4/22

2/9/2015

DocumentDisplay

dbms_output.enable(100000)
fnd_global.apps_initialize(USER_ID=>1007882,
resp_id=>NULL,
resp_appl_id=>NULL)
p_batch_header.plant_code:='PR1'
p_batch_header.batch_no:=''
p_batch_header.batch_type:=0
p_batch_header.plan_start_date:=TO_DATE('16JULY200612:00:00','DDMONYYYYHH24:MI:SS')
p_batch_header.wip_whse_code:=''
gme_api_pub.create_batch(
p_api_version
,p_validation_level=>100
,p_init_msg_list=>TRUE
,p_commit=>FALSE
,x_message_count=>x_message_count
,x_message_list=>x_message_list
,x_return_status=>x_return_status
,p_batch_header=>p_batch_header
,x_batch_header=>x_batch_header
,p_batch_size=>100
,p_batch_size_uom=>'KG'
,p_creation_mode=>'PRODUCT'
,p_recipe_id=>null
,p_recipe_no=>null
,p_recipe_version=>null
,p_product_no=>'JGC_1'
,p_product_id=>NULL
,p_ignore_qty_below_cap=>TRUE
,p_ignore_shortages=>TRUE
,x_unallocated_material=>x_unallocated_material
)
gme_debug.display_messages(x_message_count)
dbms_output.put_line('x_message_count='||TO_CHAR(x_message_count))
dbms_output.put_line('x_message_list='||x_message_list)
dbms_output.put_line('x_return_status='||x_return_status)
dbms_output.put_line('x_batch_header.batch_id='||TO_CHAR(x_batch_header.batch_id))
dbms_output.put_line(SubStr('x_batch_header.plant_code='||x_batch_header.plant_code,1,255))
dbms_output.put_line(SubStr('x_batch_header.batch_no='||x_batch_header.batch_no,1,255))
dbms_output.put_line('x_batch_header.batch_type='||TO_CHAR(x_batch_header.batch_type))
dbms_output.put_line('x_batch_header.recipe_validity_rule_id
='||TO_CHAR(x_batch_header.recipe_validity_rule_id))
dbms_output.put_line('x_batch_header.formula_id='||TO_CHAR(x_batch_header.formula_id))
dbms_output.put_line('x_batch_header.routing_id='||TO_CHAR(x_batch_header.routing_id))
dbms_output.put_line('x_batch_header.plan_start_date='||TO_CHAR(x_batch_header.plan_start_date,
'DDMONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.due_date='||TO_CHAR(x_batch_header.due_date,'DDMON
YYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.plan_cmplt_date=
'||TO_CHAR(x_batch_header.plan_cmplt_date,'DDMONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.batch_status='||TO_CHAR(x_batch_header.batch_status))
dbms_output.put_line(SubStr('x_batch_header.wip_whse_code
='||x_batch_header.wip_whse_code,1,255))
dbms_output.put_line(SubStr('x_batch_header.poc_ind='||x_batch_header.poc_ind,1,255))
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

5/22

2/9/2015

DocumentDisplay

dbms_output.put_line(SubStr('x_batch_header.update_inventory_ind=
'||x_batch_header.update_inventory_ind,1,255))
dbms_output.put_line('x_batch_header.last_update_date='||TO_CHAR(x_batch_header.last_update_date,
'DDMONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.last_updated_by=
'||TO_CHAR(x_batch_header.last_updated_by))
dbms_output.put_line('x_batch_header.creation_date='||TO_CHAR(x_batch_header.creation_date,'DD
MONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.created_by='||TO_CHAR(x_batch_header.created_by))
dbms_output.put_line('x_batch_header.last_update_login
='||TO_CHAR(x_batch_header.last_update_login))
dbms_output.put_line('x_batch_header.delete_mark='||TO_CHAR(x_batch_header.delete_mark))
dbms_output.put_line('x_batch_header.text_code='||TO_CHAR(x_batch_header.text_code))
dbms_output.put_line('x_batch_header.automatic_step_calculation
='||TO_CHAR(x_batch_header.automatic_step_calculation))
IFx_unallocated_material.count>0THEN
FORiINx_unallocated_material.first..x_unallocated_material.lastLOOP
IFx_unallocated_material.exists(i)THEN

dbms_output.put_line('x_unallocated_material('||to_char(i)||').batch_id
='||TO_CHAR(x_unallocated_material(i).batch_id))
dbms_output.put_line(SubStr('x_unallocated_material('||to_char(i)||').batch_no
='||x_unallocated_material(i).batch_no,1,255))
dbms_output.put_line('x_unallocated_material('||to_char(i)||').material_detail_id='||TO_CHAR(x_unallocated_ma
dbms_output.put_line('x_unallocated_material('||to_char(i)||').line_type='||TO_CHAR(x_unallocated_material(i).
dbms_output.put_line('x_unallocated_material('||to_char(i)||').line_no='||TO_CHAR(x_unallocated_material(i).lin
dbms_output.put_line('x_unallocated_material('||to_char(i)||').item_id='||TO_CHAR(x_unallocated_material(i).ite
dbms_output.put_line(SubStr('x_unallocated_material('||to_char(i)||').item_no
='||x_unallocated_material(i).item_no,1,255))
dbms_output.put_line('x_unallocated_material('||to_char(i)||').alloc_qty='||TO_CHAR(x_unallocated_material(i).
dbms_output.put_line('x_unallocated_material('||to_char(i)||').unalloc_qty
='||TO_CHAR(x_unallocated_material(i).unalloc_qty))
dbms_output.put_line(SubStr('x_unallocated_material('||to_char(i)||').alloc_uom='||x_unallocated_material(i).all
ENDIF
ENDLOOP
ENDIF
gme_api_pub.save_batch(
p_batch_header=>p_batch_header,
X_return_status=>x_return_status,
p_commit=>TRUE)
EXCEPTION
WHENOTHERSTHEN
dbms_output.put_line('Error'||TO_CHAR(SQLCODE)||':'||SQLERRM)
RAISE
END
/

RemarksonExample2
1. TheremarksmadeagainstExample1remainvalidforExample2.Inadditionpleasenotethe
following.
2. Inthisexample,theproducttobeoutputisspecifiedandthequantitytobeoutputislikewise
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

6/22

2/9/2015

DocumentDisplay

specified.Onceagain,however,theremustbeavalidRecipeValidityRulethatcanusedtocreate
thebatch.Seeremark3onexample1formoredetails.
3. NoticethatwhentheAPIcreatingthebatch(gme_api_pub.create_batch)isrun,thetransaction
isnotcommitted.Insteadthisisdoneatalaterstageusingthe'gme_api_pub.save_batch'API.
Theusermaycaretousethistechniquewhen,forexample,creatingandreleasingabatchina
singletransaction.

Example3:CreationusingOutputQuantity
setserveroutputon
altersessionsetnls_language=american
DECLARE
x_message_countNUMBER
x_message_listVARCHAR2(2000)
x_return_statusVARCHAR2(1)
p_batch_headerGME_BATCH_HEADER%rowtype
x_batch_headerGME_BATCH_HEADER%rowtype
x_unallocated_materialGME_API_PUB.UNALLOCATED_MATERIALS_TAB
l_msg_index_outNUMBER
BEGIN
Followinglineissettheoutputbuffer
dbms_output.enable(100000)
/**************************************************************************************
*Enteryouruseridbelow
*NOTE:Toretrieveuser_idLogontotheapplication.
*SelecttoProductionSupervisorresponsibility
*NavigateOthers>Sessionparameters
*YouwillseeyourUSERIDandUsernameonthescreen.
*fnd_profile.initialize(user_id)
**************************************************************************************/
settheapplicationscontext
fnd_global.apps_initialize(USER_ID=>1007882,
resp_id=>NULL,
resp_appl_id=>NULL
)
/**************************************************************************************
*(R)=Required,(O)=Optional
*enteryourownplant_code(R),recipe_validity_Rule_Id(O),batch_type(R)
*specifybatch_no(Riftestingmanualdocordering)
*datesareoptionalformatofthedatesis
*TO_DATE('10OCT200112:00:00','DDMONYYYYHH24:MI:SS')
*Inesenceyousupplythedateandappropriateformat.
*wip_whse_codeisoptional.
*update_inventory_indisoptionalandshouldonlybeusediftheplantisaLab.
*'Y'=Transactionstobecreated,'N'=transactionsshouldnotbecreated.
**************************************************************************************/
p_batch_header.plant_code:='PR1'p_batch_header.batch_no:=''
batch_type..10=fpo,0=batch
p_batch_header.batch_type:=0
p_batch_header.recipe_validity_rule_id:=null
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

7/22

2/9/2015

DocumentDisplay

p_batch_header.plan_start_date:=''TO_DATE('30JUL200612:00:00','DDMONYYYY
HH24:MI:SS')
p_batch_header.due_date:=''TO_DATE('')
p_batch_header.plan_cmplt_date:=''TO_DATE('')
p_batch_header.wip_whse_code:=''
youhavetheoptiontosetthebelowparamtoNwhentestingLabbatchcreation
p_batch_header.update_inventory_ind:='Y'
/**************************************************************************************
*Nowcallthestoredprogram
*Leavefirst4parametersastheyare
*enterp_batch_sizeandp_batch_size_uomarerequired
*ifp_creation_modeis'PRODUCT','OUTPUT','INPUT')
*enterp_creation_mode=RECIPE,PRODUCT,OUTPUT,INPUT
*p_batch_header_validity_rule_idORp_recipe_idOR(p_recipe_noandp_recipe_version)
*arerequiredifp_creation_mode='RECIPE','INPUT','OUTPUT'
*p_batch_header_validity_rule_idORp_product_idORp_product_no
*arerequiredifp_creation_mode='PRODUCT'
*Ifp_ignore_shortagesidpassedasFALSEthenincaseofshortages
*andprofileoptionGMI:AllownegativeinventoryissettoWarningorError
*Batchwillnotbecreatedandthex_unallocatedprocedurewillbepopulated
*withthemateriallinescausingshortages.
*p_ignore_qty_below_cap:IfsettoFALSE,theniftheprocessquantityofanyof
*theresourcesinthebatchislessthantheminimumcapacityforthatresource
*batchwillnotbecreated.
**************************************************************************************/
gme_api_pub.create_batch(
,p_api_version=>1
,p_validation_level=>100
,p_init_msg_list=>TRUE
,p_commit=>TRUE
,x_message_count=>x_message_count
,x_message_list=>x_message_list
,x_return_status=>x_return_status
,p_batch_header=>p_batch_header
,x_batch_header=>x_batch_header
,p_batch_size=>1000
,p_batch_size_uom=>'KG'
,p_creation_mode=>'OUTPUT'
,p_recipe_id=>NULL
,p_recipe_no=>'JGC_1'
,p_recipe_version=>'301'
,p_product_no=>'JGC_1'
,p_product_id=>NULL
,p_ignore_qty_below_cap=>TRUE
,p_ignore_shortages=>TRUE
,x_unallocated_material=>x_unallocated_material
)
/***************************************************************************************
*Followinglinecanbeuncommented,iftherearemultiplemessagesreturnbythe
*API,andyouwanttoseeallthosemessages.ThesewillbewrittentotheLogfile
*IfgeneratedbytheAPI.
***************************************************************************************/
gme_debug.display_messages(x_message_count)
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

8/22

2/9/2015

DocumentDisplay

/***************************************************************************************
*Outputtheresults
*OneofthefollowingwillbetheoutcomeoftheAPIcall(x_return_status)
*SSuccess
*EError
*UUnexpectedError
*NItemsfailedautoallocation
*VInventoryshortageexists
***************************************************************************************/
IFx_return_status<>FND_API.g_ret_sts_successTHEN
IFX_message_count=1THEN
DBMS_OUTPUT.PUT_LINE('Error:'||X_message_list)
ELSE
FORiIN1..x_message_countLOOP
FND_MSG_PUB.get(p_msg_index=>i
,p_data=>X_message_list
,p_msg_index_out=>l_msg_index_out)
DBMS_OUTPUT.PUT_LINE('Error:'||X_message_list)
ENDLOOP
ENDIF
ELSE
dbms_output.put_line('x_message_count='||TO_CHAR(x_message_count))
dbms_output.put_line('x_message_list=
'||length(x_message_list)||SubStr(x_message_list,length(x_message_list)20,20))
dbms_output.put_line('x_return_status='||x_return_status)
dbms_output.put_line('x_batch_header.batch_id='||TO_CHAR(x_batch_header.batch_id))
dbms_output.put_line(SubStr('x_batch_header.plant_code='||x_batch_header.plant_code,1,255))
dbms_output.put_line(SubStr('x_batch_header.batch_no='||x_batch_header.batch_no,1,255))
dbms_output.put_line('x_batch_header.batch_type='||TO_CHAR(x_batch_header.batch_type))
dbms_output.put_line('x_batch_header.recipe_validity_rule_id=
'||TO_CHAR(x_batch_header.recipe_validity_rule_id))
dbms_output.put_line('x_batch_header.formula_id='||TO_CHAR(x_batch_header.formula_id))
dbms_output.put_line('x_batch_header.routing_id='||TO_CHAR(x_batch_header.routing_id))
dbms_output.put_line('x_batch_header.plan_start_date='||TO_CHAR(x_batch_header.plan_start_date,
'DDMONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.due_date='||TO_CHAR(x_batch_header.due_date,'DDMON
YYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.plan_cmplt_date=
'||TO_CHAR(x_batch_header.plan_cmplt_date,'DDMONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.batch_status='||TO_CHAR(x_batch_header.batch_status))
dbms_output.put_line(SubStr('x_batch_header.wip_whse_code=
'||x_batch_header.wip_whse_code,1,255))
dbms_output.put_line(SubStr('x_batch_header.poc_ind='||x_batch_header.poc_ind,1,255))
dbms_output.put_line(SubStr('x_batch_header.update_inventory_ind=
'||x_batch_header.update_inventory_ind,1,255))
dbms_output.put_line('x_batch_header.last_update_date=
'||TO_CHAR(x_batch_header.last_update_date,'DDMONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.last_updated_by=
'||TO_CHAR(x_batch_header.last_updated_by))
dbms_output.put_line('x_batch_header.creation_date='||TO_CHAR(x_batch_header.creation_date,'DD
MONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.created_by='||TO_CHAR(x_batch_header.created_by))
dbms_output.put_line('x_batch_header.last_update_login=
'||TO_CHAR(x_batch_header.last_update_login))
dbms_output.put_line('x_batch_header.delete_mark='||TO_CHAR(x_batch_header.delete_mark))
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

9/22

2/9/2015

DocumentDisplay

dbms_output.put_line('x_batch_header.text_code='||TO_CHAR(x_batch_header.text_code))
dbms_output.put_line('x_batch_header.automatic_step_calculation=
'||TO_CHAR(x_batch_header.automatic_step_calculation))
IFx_unallocated_material.count>0THEN
FORiINx_unallocated_material.first..x_unallocated_material.lastLOOP
IFx_unallocated_material.exists(i)THEN
dbms_output.put_line('x_unallocated_material('||to_char(i)||').batch_id=
'||TO_CHAR(x_unallocated_material(i).batch_id))
dbms_output.put_line(SubStr('x_unallocated_material('||to_char(i)||').batch_no=
'||x_unallocated_material(i).batch_no,1,255))
dbms_output.put_line('x_unallocated_material('||to_char(i)||').material_detail_id=
'||TO_CHAR(x_unallocated_material(i).material_detail_id))
dbms_output.put_line('x_unallocated_material('||to_char(i)||').line_type=
'||TO_CHAR(x_unallocated_material(i).line_type))
dbms_output.put_line('x_unallocated_material('||to_char(i)||').line_no=
'||TO_CHAR(x_unallocated_material(i).line_no))
dbms_output.put_line('x_unallocated_material('||to_char(i)||').item_id=
'||TO_CHAR(x_unallocated_material(i).item_id))
dbms_output.put_line(SubStr('x_unallocated_material('||to_char(i)||').item_no=
'||x_unallocated_material(i).item_no,1,255))
dbms_output.put_line('x_unallocated_material('||to_char(i)||').alloc_qty=
'||TO_CHAR(x_unallocated_material(i).alloc_qty))
dbms_output.put_line('x_unallocated_material('||to_char(i)||').unalloc_qty=
'||TO_CHAR(x_unallocated_material(i).unalloc_qty))
dbms_output.put_line(SubStr('x_unallocated_material('||to_char(i)||').alloc_uom=
'||x_unallocated_material(i).alloc_uom,1,255))
ENDIF
ENDLOOP
ENDIF
ENDIF
EXCEPTION
WHENOTHERSTHEN
dbms_output.put_line('Error'||TO_CHAR(SQLCODE)||':'||SQLERRM)
RAISE
END
/

Remarksonexample3
1. SeeRemarksforbothExample1andExample2.AsinExample1,theRecipeandVersion
numbersarespecifiedandlikeExample2,theProductisspecified.Thisexamplediffersfromthe
othersinthatitallowstheusertocontrolboththerecipeusedandtheoutputquantity.Itbasically
providesthesamefunctionalityasusingtheTotalOutputtabwhencreatingabatchinthe
application.

Example4:Create,ReleaseandSaveBatch
altersessionsetnls_language=american
setserveroutputonsize100000
DECLARE
l_batch_headergme_batch_header%ROWTYPE
x_batch_headergme_batch_header%ROWTYPE
p_batch_headergme_batch_header%ROWTYPE
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

10/22

2/9/2015

DocumentDisplay

x_message_countNUMBER
x_message_listVARCHAR2(2000)
x_unallocated_materialgme_api_pub.unallocated_materials_tab
x_return_statusVARCHAR2(1)
l_material_detailgme_material_details%ROWTYPE
x_material_detailgme_material_details%ROWTYPE
p_values_tabgme_api_pub.field_values_tab
l_fieldgme_api_pub.p_field
l_unallocated_materialgme_api_pub.unallocated_materials_tab
l_msg_index_outNUMBER
BEGIN
Settheapplicationscontext
fnd_global.apps_initialize(USER_ID=>1007882,
resp_id=>NULL,
resp_appl_id=>NULL)
l_batch_header.plant_code:='PR1'
l_batch_header.batch_type:=0
l_batch_header.plan_start_date:=SYSDATE
l_batch_header.plan_cmplt_date:=SYSDATE
l_batch_header.due_date:=SYSDATE
l_batch_header.update_inventory_ind:='Y'
l_batch_header.wip_whse_code:='PR1'
l_batch_header.recipe_validity_rule_id:=1239

CREATETHEBATCH

gme_api_pub.create_batch(p_api_version=>1
,p_validation_level=>1000
,p_init_msg_list=>TRUE
,p_commit=>FALSE
,x_message_count=>x_message_count
,x_message_list=>x_message_list
,x_return_status=>x_return_status
,p_batch_header=>l_batch_header
,x_batch_header=>x_batch_header
,p_batch_size=>10
,p_batch_size_uom=>'KG'
,p_creation_mode=>'RECIPE'
,p_recipe_id=>NULL
,p_recipe_no=>'JGC_1'
,p_recipe_version=>'301'
,p_product_no=>NULL
,p_product_id=>NULL
,p_ignore_qty_below_cap=>TRUE
,p_ignore_shortages=>TRUE
,x_unallocated_material=>x_unallocated_material)
IFx_return_status<>FND_API.g_ret_sts_successTHEN
IFX_message_count=1THEN
DBMS_OUTPUT.PUT_LINE('Error:'||X_message_list)
ELSE
FORiIN1..x_message_countLOOP
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

11/22

2/9/2015

DocumentDisplay

FND_MSG_PUB.get(p_msg_index=>i
,p_data=>X_message_list
,p_msg_index_out=>l_msg_index_out)
DBMS_OUTPUT.PUT_LINE('Error:'||X_message_list)
ENDLOOP
ENDIF
ELSE
dbms_output.put_line('x_message_count='||TO_CHAR(x_message_count))
dbms_output.put_line('x_message_list=length'||length(x_message_list)||'Contents'
||substr(x_message_list,1,200))
dbms_output.put_line('x_return_status='||x_return_status)
dbms_output.put_line('x_batch_header.batch_id='||TO_CHAR(x_batch_header.batch_id))
dbms_output.put_line(SubStr('x_batch_header.plant_code='||x_batch_header.plant_code,1,255))
dbms_output.put_line(SubStr('x_batch_header.batch_no='||x_batch_header.batch_no,1,255))
dbms_output.put_line('x_batch_header.batch_type='||TO_CHAR(x_batch_header.batch_type))
dbms_output.put_line('x_batch_header.recipe_validity_rule_id=
'||TO_CHAR(x_batch_header.recipe_validity_rule_id))
dbms_output.put_line('x_batch_header.formula_id='||TO_CHAR(x_batch_header.formula_id))
dbms_output.put_line('x_batch_header.routing_id='||TO_CHAR(x_batch_header.routing_id))
dbms_output.put_line('x_batch_header.plan_start_date=
'||TO_CHAR(x_batch_header.plan_start_date,'DDMONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.due_date='||TO_CHAR(x_batch_header.due_date,'DD
MONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.plan_cmplt_date=
'||TO_CHAR(x_batch_header.plan_cmplt_date,'DDMONYYYYHH24:MI:SS')
dbms_output.put_line('x_batch_header.batch_status='||TO_CHAR(x_batch_header.batch_status))
l_batch_header.batch_type:=0
l_batch_header.batch_id:=x_batch_header.batch_id
l_batch_header.plan_start_date:=SYSDATE
l_batch_header.plan_cmplt_date:=SYSDATE
l_batch_header.due_date:=SYSDATE
l_batch_header.update_inventory_ind:='Y'
l_batch_header.actual_start_date:=SYSDATE

RELEASEIT

gme_api_pub.release_batch(p_api_version=>1
,p_validation_level=>1000
,p_init_msg_list=>TRUE
,p_commit=>FALSE
,x_message_count=>x_message_count
,x_message_list=>x_message_list
,x_return_status=>x_return_status
,p_batch_header=>l_batch_header
,x_batch_header=>x_batch_header
,p_ignore_shortages=>TRUE
,x_unallocated_material=>l_unallocated_material
,p_ignore_unalloc=>TRUE)
IFx_return_status=FND_API.g_ret_sts_successTHEN
dbms_output.put_line('BatchReleased')
p_batch_header.batch_id:=x_batch_header.batch_id

SAVETHECHANGES
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

12/22

2/9/2015

DocumentDisplay

gme_api_pub.save_batch(
p_batch_header=>p_batch_header,
X_return_status=>x_return_status,
p_commit=>TRUE)
else
dbms_output.put_line('BatchReleasefailed')
IFX_message_count=1THEN
DBMS_OUTPUT.PUT_LINE('Error:'||X_message_list)
ELSE
FORiIN1..x_message_countLOOP
FND_MSG_PUB.get(p_msg_index=>i
,p_data=>X_message_list
,p_msg_index_out=>l_msg_index_out)
DBMS_OUTPUT.PUT_LINE('Error:'||X_message_list)
ENDLOOP
endif
endif
endif
EXCEPTION
WHENOTHERSTHEN
dbms_output.put_line('Error'||TO_CHAR(SQLCODE)||':'||SQLERRM)
RAISE
END
/

Remarksonexample4
Thisscriptcreates,releasesandsavesabatch.Notethatwhenthebatchiscreatedandreleased,
thesechangesarenotcommitted(thatistosay,'p_commit'issettoFalse).Thisenablestheuser
totreatbothbatchcreationandreleaseaspartofthesametransactionandcommitthechanges
ifbothoperationssucceed.

Example5:Createabatchandinsertanadditionalmaterialline
altersessionsetnls_language=american
setserveroutputonsize100000
DECLARE
l_batch_headergme_batch_header%ROWTYPE
x_batch_headergme_batch_header%ROWTYPE
p_batch_headergme_batch_header%ROWTYPE
x_message_countNUMBER
x_message_listVARCHAR2(2000)
x_unallocated_materialgme_api_pub.unallocated_materials_tab
x_return_statusVARCHAR2(1)
l_material_detailgme_material_details%ROWTYPE
x_material_detailgme_material_details%ROWTYPE
p_values_tabgme_api_pub.field_values_tab
l_fieldgme_api_pub.p_field
l_unallocated_materialgme_api_pub.unallocated_materials_tab
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

13/22

2/9/2015

DocumentDisplay

l_msg_index_outNUMBER
BEGIN
Settheapplicationscontext
fnd_global.apps_initialize(USER_ID=>1007882,
resp_id=>NULL,
resp_appl_id=>NULL)
l_batch_header.plant_code:='PR1'
l_batch_header.batch_type:=0
l_batch_header.plan_start_date:=SYSDATE
l_batch_header.plan_cmplt_date:=SYSDATE
l_batch_header.due_date:=SYSDATE
l_batch_header.update_inventory_ind:='Y'
l_batch_header.wip_whse_code:='PR1'
l_batch_header.recipe_validity_rule_id:=1239

CREATETHEBATCH

gme_api_pub.create_batch(p_api_version=>1
,p_validation_level=>1000
,p_init_msg_list=>TRUE
,p_commit=>FALSE
,x_message_count=>x_message_count
,x_message_list=>x_message_list
,x_return_status=>x_return_status
,p_batch_header=>l_batch_header
,x_batch_header=>x_batch_header
,p_batch_size=>10
,p_batch_size_uom=>'KG'
,p_creation_mode=>'RECIPE'
,p_recipe_id=>NULL
,p_recipe_no=>'JGC_1'
,p_recipe_version=>'301'
,p_product_no=>NULL
,p_product_id=>NULL
,p_ignore_qty_below_cap=>TRUE
,p_ignore_shortages=>TRUE
,x_unallocated_material=>x_unallocated_material)
IFx_return_status<>FND_API.g_ret_sts_successTHEN
DBMS_OUTPUT.PUT_LINE('Error:'||X_message_list)
ELSE
dbms_output.put_line('x_message_count='||TO_CHAR(x_message_count))
dbms_output.put_line('x_message_list=lenght'||length(x_message_list)||'Contents'
||substr(x_message_list,1,200))
dbms_output.put_line('x_return_status='||x_return_status)
dbms_output.put_line('x_batch_header.batch_id='||TO_CHAR(x_batch_header.batch_id))
dbms_output.put_line(SubStr('x_batch_header.plant_code='||x_batch_header.plant_code,1,255))
dbms_output.put_line(SubStr('x_batch_header.batch_no='||x_batch_header.batch_no,1,255))
dbms_output.put_line('x_batch_header.batch_type='||TO_CHAR(x_batch_header.batch_type))
dbms_output.put_line('x_batch_header.recipe_validity_rule_id=
'||TO_CHAR(x_batch_header.recipe_validity_rule_id))
dbms_output.put_line('x_batch_header.formula_id='||TO_CHAR(x_batch_header.formula_id))
dbms_output.put_line('x_batch_header.routing_id='||TO_CHAR(x_batch_header.routing_id))
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

14/22

2/9/2015

DocumentDisplay

dbms_output.put_line('x_batch_header.plan_start_date=
'||TO_CHAR(x_batch_header.plan_start_date,'DDMONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.due_date='||TO_CHAR(x_batch_header.due_date,'DD
MONYYYYHH24:MI:SS'))
dbms_output.put_line('x_batch_header.plan_cmplt_date=
'||TO_CHAR(x_batch_header.plan_cmplt_date,'DDMONYYYYHH24:MI:SS')
dbms_output.put_line('x_batch_header.batch_status='||TO_CHAR(x_batch_header.batch_status))
l_material_detail.batch_id:=x_batch_header.batch_id
l_material_detail.line_no:=2
l_material_detail.item_id:=712
l_material_detail.plan_qty:=100
l_material_detail.scale_type:=1
l_material_detail.alloc_ind:=0
l_material_detail.item_um:='LB'
l_material_detail.line_type:=1
l_material_detail.cost_alloc:=0
l_material_detail.contribute_yield_ind:='Y'
l_material_detail.scrap_factor:=0
l_material_detail.phantom_type:=0
p_batch_header:=x_batch_header

INSERTINGREDIENTLINE

gme_api_pub.insert_material_line(p_api_version=>1
,p_validation_level=>100
,p_init_msg_list=>FALSE
,p_commit=>FALSE
,x_message_count=>x_message_count
,x_message_list=>x_message_list
,x_return_status=>x_return_status
,p_material_detail=>l_material_detail
,p_batchstep_no=>NULL
,x_material_detail=>x_material_detail)
IFx_return_status=FND_API.g_ret_sts_successTHEN
dbms_output.put_line('Materiallineinsertedforitemid'||x_material_detail.item_id)

SAVETHECHANGES

gme_api_pub.save_batch(
p_batch_header=>p_batch_header,
X_return_status=>x_return_status,
p_commit=>TRUE)
else
dbms_output.put_line('Materiallineinsertionfailed')
DBMS_OUTPUT.PUT_LINE('Error:'||X_message_list)
endif
endif
EXCEPTION
WHENOTHERSTHEN
dbms_output.put_line('Error'||TO_CHAR(SQLCODE)||':'||SQLERRM)
RAISE
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

15/22

2/9/2015

DocumentDisplay

END
/

RemarksonExample5
ThisissimilartoExample4exceptthatthistime,oncethebatchiscreated,anew
ingredientlineisadded.ThechangesarethensavedviathesavebatchAPI.

Example6:Insert_line_allocationAPI
setserveroutonsize100000
altersessionsetnls_language=american
DECLARE

x_message_countNUMBER
x_message_listVARCHAR2(2000)
x_return_statusVARCHAR2(2000)
p_material_detailsgme_material_details%ROWTYPE
x_material_detailsgme_material_details%ROWTYPE
p_batch_headergme_batch_header%ROWTYPE
x_def_tran_rowgme_inventory_txns_gtmp%ROWTYPE
x_tran_rowgme_inventory_txns_gtmp%ROWTYPE
x_unallocated_materialsgme_api_pub.unallocated_materials_tab
x_unallocated_itemsgme_unallocated_items_gtmp%rowtype
p_tran_rowgme_inventory_txns_gtmp%ROWTYPE

x_msg_indexnumber
x_msg_datavarchar2(200)
l_message_countNUMBER
l_message_listVARCHAR2(200)
BEGIN
Followinglineissettheoutputbuffer
DBMS_OUTPUT.enable(20000)
Linebelowrequiredifformulasecurityisused.Itsetsthesecuritycontext.
fnd_global.apps_initialize(USER_ID=>1007882,
resp_id=>NULL,
resp_appl_id=>NULL
)

p_material_details.material_detail_id:=22188
p_batch_header.batch_id:=4354

/**/
p_tran_row.doc_id:=4354
p_tran_row.material_detail_id:=22188
p_tran_row.whse_code:='PR1'
p_tran_row.location:='1'
p_tran_row.lot_id:=7571
p_tran_row.alloc_qty:=100
p_tran_row.trans_qty:=100
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

16/22

2/9/2015

DocumentDisplay

p_tran_row.completed_ind:=0
p_tran_row.trans_date:=sysdate
p_tran_row.reason_code:=null
/**************************************************************************************
*Nowcallthestoredprogram*
*Leavefirst4parametersastheyare*
**************************************************************************************/
gme_api_pub.insert_line_allocation(p_api_version=>1
p_validation_level=>1000
,p_init_msg_list=>TRUE
,p_commit=>TRUE
,p_tran_row=>p_tran_row
,p_lot_no=>null
,p_sublot_no=>null
,p_create_lot=>TRUE
,p_ignore_shortage=>FALSE
,p_scale_phantom=>FALSE
,x_material_detail=>p_material_details
,x_tran_row=>x_tran_row
,x_def_tran_row=>x_def_tran_row
,x_message_count=>l_message_count
,x_message_list=>l_message_list
,x_return_status=>x_return_status)
IFx_return_status=FND_API.g_ret_sts_successTHEN
DBMS_OUTPUT.put_line('doc_id='||x_tran_row.doc_id)
DBMS_OUTPUT.put_line('material_detail_id='||x_tran_row.material_detail_id)
DBMS_OUTPUT.put_line('trans_id='||x_tran_row.trans_id)
DBMS_OUTPUT.put_line('line_type='||x_tran_row.line_type)
DBMS_OUTPUT.put_line('whse_code='||x_tran_row.whse_code)
DBMS_OUTPUT.put_line('location='||x_tran_row.location)
DBMS_OUTPUT.put_line('alloc_qty='||x_tran_row.alloc_qty)
DBMS_OUTPUT.put_line('trans_qty='||x_tran_row.trans_qty)
DBMS_OUTPUT.put_line('trans_qty2='||x_tran_row.trans_qty2)
DBMS_OUTPUT.put_line('completed_ind='||x_tran_row.completed_ind)
DBMS_OUTPUT.put_line('trans_date='||x_tran_row.trans_date)
else
DBMS_OUTPUT.put_line('x_message_count='||TO_CHAR(L_message_count))
DBMS_OUTPUT.put_line(SubStr('x_message_list='||l_message_list,1,255))
DBMS_OUTPUT.put_line(SubStr('x_return_status='||x_return_status,1,255))
endif
EXCEPTION
WHENOTHERSTHEN
DBMS_OUTPUT.put_line('Error'||TO_CHAR(SQLCODE)||':'||SQLERRM)
RAISE
END
/

RemarksonExample6
Thiswillcreatealineallocationforeitheraningredientorproductline.NotethisAPIcanbeused
inconjunctionwiththegme_api_pub.insert_material_lineAPItobothaddandallocateanew
materialline.Onceagainthegme_api_pub.save_batchprocedurecanbeusedtosaveboth
transactionsoncetheuserissuretherearenoerrors.
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

17/22

2/9/2015

DocumentDisplay

Example7:Close(Complete)Batch
altersessionsetnls_language=american
setserveroutputonsize1000000
DECLARE
v_batch_headerapps.gme_batch_header%ROWTYPE
x_batch_headerapps.gme_batch_header%ROWTYPE
v_message_countnumber
v_message_listVARCHAR2(1024)
v_unallocated_materialapps.gme_api_pub.unallocated_materials_tab
v_return_statusVARCHAR2(1)
BEGIN
fnd_global.apps_initialize(USER_ID=>1007882,
resp_id=>NULL,
resp_appl_id=>NULL)
v_batch_header.batch_id:=4355
v_batch_header.ACTUAL_CMPLT_DATE:=sysdate
gme_api_pub.certify_batch(
p_init_msg_list=>TRUE
,p_commit=>false
,x_message_count=>v_message_count
,x_message_list=>v_message_list
,x_return_status=>v_return_status
,p_del_incomplete_manual=>TRUE
,p_ignore_shortages=>TRUE
,p_batch_header=>v_batch_header
,x_batch_header=>x_batch_header
,x_unallocated_material=>v_unallocated_material)
IFv_return_status='S'THEN
dbms_output.put_line('Certifysucceeded')
gme_api_pub.save_batch(x_batch_header,v_return_status)
dbms_output.put_line('save_batch:status='||v_return_status)
commit
else
dbms_output.put_line('Certifyfailedstatus='||v_return_status)
DBMS_OUTPUT.PUT_LINE('Error:'||v_message_list)
rollback
endif
EXCEPTION
WHENOTHERSTHEN
dbms_output.put_line('Error'||TO_CHAR(SQLCODE)||':'||SQLERRM)
RAISE
END
/

Remarksonexample7
Bearinmindthestatethebatchmustbeinbeforeitcancompletedthatis,thequantity
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

18/22

2/9/2015

DocumentDisplay

oftheoutputproductshouldhavebeenrecordedandtheingredientsallocated.Iftheuser
hasanydoubtsaboutthis,itissuggestedthattheycreate,release,allocateandattemptto
completeabatchintheApplication.Ifthiscanbedoneintheapplicationthenabatchin
thesamestateshouldbeabletobecompletedusingtheAPI.Noticealsointhisexample
thecommitisdoneattheendofthescripti.e.afterthesavebatch.

Example8:Release,RecordUsageandCompletestep
altersessionsetnls_language=american
setserveroutputonsize1000000
DECLARE
v_message_countnumber
v_message_listVARCHAR2(1024)
v_return_statusVARCHAR2(1)
v_batch_headergme_batch_header%ROWTYPE
x_batch_headergme_batch_header%ROWTYPE
v_batch_stepgme_batch_steps%ROWTYPE
x_batch_stepgme_batch_steps%ROWTYPE
l_releaseboolean:=false
l_usageboolean:=false
l_certifyboolean:=false
v_unallocated_materialgme_api_pub.unallocated_materials_tab
l_batchstep_idnumber
l_batch_idnumber
x_poc_trans_idnumber
BEGIN
fnd_global.apps_initialize(USER_ID=>1007882,
resp_id=>NULL,
resp_appl_id=>NULL)

Getbatchdetails

select*intov_batch_header
fromgme_batch_header
wherebatch_id=4362

releasestep10

v_batch_step.batchstep_no:=10
v_batch_step.batch_id:=v_batch_header.batch_id
v_batch_step.actual_start_date:=v_batch_header.actual_start_date
gme_api_pub.release_step(
p_init_msg_list=>TRUE
,p_commit=>FALSE
,p_batch_step=>v_batch_step
,x_message_count=>v_message_count
,x_message_list=>v_message_list
,x_return_status=>v_return_status
,x_batch_step=>x_batch_step
,x_unallocated_material=>v_unallocated_material
,p_ignore_shortages=>TRUE
,p_ignore_unalloc=>TRUE)
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

19/22

2/9/2015

DocumentDisplay

ifv_return_status='S'then
l_release:=true
l_batch_id:=x_batch_step.batch_id
l_batchstep_id:=x_batch_step.batchstep_id
dbms_output.put_line('Releasestepsucceeded')
else
dbms_output.put_line('release_step:status='||v_return_status||',message='||v_message_list)
rollback
endif

Recordresourceusage

ifl_release=truethen
forc1in(selectbatchstep_resource_id
,resources
,activity
from
gme_batch_step_resourcesr
,gme_batch_step_activitiesa
where
r.batchstep_id=x_batch_step.batchstep_id
anda.batchstep_id=r.batchstep_id
anda.batch_id=x_batch_step.batch_id
andr.batchstep_activity_id=a.batchstep_activity_id)
loop
gme_api_pub.update_actual_rsrc_usage(
p_init_msg_list=>TRUE
,p_commit=>FALSE
,p_batchstep_rsrc_id=>c1.batchstep_resource_id
,p_plant_code=>v_batch_header.plant_code
,p_batch_no=>v_batch_header.batch_no
,p_batchstep_no=>x_batch_step.batchstep_no
,p_activity=>c1.activity
,p_resource=>c1.resources
,p_trans_date=>v_batch_header.actual_start_date
,p_start_date=>v_batch_header.actual_start_date
,p_end_date=>sysdate
,p_usage=>1.0
,p_reason_code=>''
,x_message_count=>v_message_count
,x_message_list=>v_message_list
,x_return_status=>v_return_status
,x_poc_trans_id=>x_poc_trans_id)
dbms_output.put_line('update_actual_rsrc_usage:status='||v_return_status||',
message='||v_message_list)
endloop
endif
ifv_return_status='S'then
l_usage:=true
else
rollback
endif

Completestep

IFl_usage=truethen
gme_api_pub.certify_step(
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

20/22

2/9/2015

DocumentDisplay

p_init_msg_list=>TRUE
,p_commit=>FALSE
,x_message_count=>v_message_count
,x_message_list=>v_message_list
,x_return_status=>v_return_status
,p_batch_step=>v_batch_step
,x_batch_step=>x_batch_step
,x_unallocated_material=>v_unallocated_material
,p_del_incomplete_manual=>FALSE
,p_ignore_shortages=>TRUE)
ifv_return_status='S'then
l_certify:=true

Savethechanges

gme_api_pub.save_batch(x_batch_header,v_return_status)
dbms_output.put_line('save_batch:status='||v_return_status)
ifv_return_status='S'then
commit
else
rollback
endif
else
dbms_output.put_line('Certifystep:status='||v_return_status||',message='||v_message_list)
rollback
endif
endif
EXCEPTION
WHENOTHERSTHEN
dbms_output.put_line('Error'||TO_CHAR(SQLCODE)||':'||SQLERRM)
RAISE
END
/

RemarksonExample8
Thisexamplereleasesabatchstep,recordsactualresourceusageandthencompletesthe
step.Assumingalloperationsaresuccessful,thechangesarethensavedusingthesave
batchAPIandthechangesarecommitted.

RelatedDocuments
OracleProcessManufacturingProcessExecutionAPIUser'sGuide

Copyright2003Oracle.Allrightsreserved.OracleisaregisteredtrademarkofOracle.Various
productandservicenamesreferencedhereinmaybetrademarksofOracle.Allotherproductand
servicenamesmentionedmaybetrademarksoftheirrespectiveowners.
Disclaimer:Thisdocumentisprovidedforinformationpurposesonlyandthecontentshereofare
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

21/22

2/9/2015

DocumentDisplay

subjecttochangewithoutnotice.Oracledoesnotwarrantthatthisdocumentiserrorfree,nordoesit
provideanyotherwarrantiesorconditions,whetherexpressedorallyorimpliedinlaw,including
impliedwarrantiesandconditionsofmerchantabilityorfitnessforaparticularpurpose.Oracle
specificallydisclaimsanyliabilitywithrespecttothisdocumentandnocontractualobligationsare
formedeitherdirectlyorindirectlybythisdocument.Thisdocumentmaynotbereproducedor
transmittedinanyformorbyanymeans,electronicormechanical,foranypurpose,withouttheprior
writtenpermissionofOracle.

https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrlstate=peadobiss_9#head4

22/22

You might also like