Sie sind auf Seite 1von 5

3/23/2017 OracleApplicationsTechnicalERPR11i,R12:AttachmentsAPIFND_DOCUMENTS_PKG,FND_ATTACHED_DOCUMENTS_PKG

OracleApplicationsTechnicalERPR11i,R12
Wednesday,April28,2010 WelcometoOracleAppsEngineering

AttachmentsAPIFND_DOCUMENTS_PKG, HavinggoodexposuretoOracleApplications
TechnicalR11iandR12,Iamgladtostartablog
FND_ATTACHED_DOCUMENTS_PKG tosharetheknowledge.

Workingonattachmentsneedsomeknowledgeofhowanattachmentfunctions(Definitions,Entity,DocumentCategory,Entities Iwillkeeppostingnewtopicswiththe
andBlocks,PrimaryKeysinattachments(Ifexists))inOracleApps.TounderstandthebelowAPIandwhatitactuallydoesits approachesusedintechnicalaspectforthe
advisabletoreadtheAttachmentsChapterinDevelopersGuide. issuesencountered.

PrimaryKeyinformationthatuniquelyidentifiestheproduct(suchastheproduct_ID). Hopethishelpnewbiesandgivessomequick
referencetoamateurs.
BelowAPItakessinglefilefromashareddriveandinsertsintofnd_lobs.Thenit'sattachedtoaparticularId(likeorder_id,
invoice_id..)usingthecombinationofpk1_value,entitynameandcategory.InthisexampleiusedPDFasattachment.Quering Haveagoodday...
thetablefnd_document_datatypeswillgivedifferentattachmenttypes.

ThissampleshowshowanattachmentAPIworks.Youcanuseittocustomize/enhancetorequirement.
SearchBlog

DECLARE
l_rowidROWID Search
l_attached_document_idNUMBER
l_document_idNUMBER
l_media_idNUMBER GoogleSearch
l_category_idNUMBER
l_pk1_valuefnd_attached_documents.pk1_value%TYPE:=<PrimaryKeyinformationthatuniquelyidentifiesthe
http://oracleappsengineering.blogspot.com/
product(suchastheproduct_ID)>
GoogleSearch
l_descriptionfnd_documents_tl.description%TYPE:='TestAttachment'
l_filenameVARCHAR2(240):='<FileName>'
l_seq_numNUMBER
l_blob_dataBLOB Followers
l_blobBLOB
l_bfileBFILE (24)
l_byteNUMBER
l_fnd_user_idNUMBER
l_short_datatype_idNUMBER
x_blobBLOB
filsBFILE
blob_lengthINTEGER
l_entity_nameVARCHAR2(100):=<entity_name>
l_category_nameVARCHAR2(100):=<category_name>
BEGIN

fnd_global.apps_initialize(<userid>,<applid>,<appluserid>) BlogArchive

2016(3)
SELECTfnd_documents_s.NEXTVAL
INTOl_document_id 2015(16)
FROMDUAL 2014(1)
2013(14)
SELECTfnd_attached_documents_s.NEXTVAL
INTOl_attached_document_id 2012(32)
FROMDUAL 2011(3)

SELECTNVL(MAX(seq_num),0)+10 2010(4)
INTOl_seq_num July(1)
FROMfnd_attached_documents June(1)
WHEREpk1_value=l_pk1_valueANDentity_name=l_entity_name
April(1)
AttachmentsAPI
FND_DOCUMENTS_PKG,
SelectUser_id
FND_ATTACHED_...
SELECTuser_id
INTOl_fnd_user_id March(1)
FROMapps.fnd_user
WHEREuser_name=<user_name> 2009(2)

GetDatatypeidforShortTexttypesofattachments
SELECTdatatype_id
AmazonDeals
INTOl_short_datatype_id
FROMapps.fnd_document_datatypes
WHERENAME='FILE'

http://oracleappsengineering.blogspot.hk/2010/04/attachmentsapifnddocumentspkg.html 1/5
3/23/2017 OracleApplicationsTechnicalERPR11i,R12:AttachmentsAPIFND_DOCUMENTS_PKG,FND_ATTACHED_DOCUMENTS_PKG
SelectCategoryidforAttachments
SELECTcategory_id
INTOl_category_id
FROMapps.fnd_document_categories_vl
WHEREUSER_NAME=l_category_name

Selectnexvaluesofdocumentid,attacheddocumentidand
l_media_id
SELECTapps.fnd_documents_s.NEXTVAL,
apps.fnd_attached_documents_s.NEXTVAL
apps.fnd_documents_long_text_s.NEXTVAL
INTOl_document_id,
l_attached_document_id
l_media_id
FROMDUAL

SELECTMAX(file_id)+1
INTOl_media_id
FROMfnd_lobs

fils:=BFILENAME(<FLIEPATH>,l_filename)

Obtainthesizeoftheblobfile
DBMS_LOB.fileopen(fils,DBMS_LOB.file_readonly)
blob_length:=DBMS_LOB.getlength(fils)
DBMS_LOB.fileclose(fils)

Insertanewrecordintothetablecontainingthe
filenameyouhavespecifiedandaLOBLOCATOR.
ReturntheLOBLOCATORandassignittox_blob.

INSERTINTOfnd_lobs
(file_id,file_name,file_content_type,upload_date,
expiration_date,program_name,program_tag,file_data,
LANGUAGE,oracle_charset,file_format
)
VALUES(l_media_id,l_filename,'application/pdf','text/plain',application/pdf
SYSDATE,
NULL,'FNDATTCH',NULL,EMPTY_BLOB(),l_blob_data,
'US','UTF8','binary'
)
RETURNINGfile_data
INTOx_blob

LoadthefileintothedatabaseasaBLOB
DBMS_LOB.OPEN(fils,DBMS_LOB.lob_readonly)
DBMS_LOB.OPEN(x_blob,DBMS_LOB.lob_readwrite)
DBMS_LOB.loadfromfile(x_blob,fils,blob_length)
Closehandlestoblobandfile
DBMS_LOB.CLOSE(x_blob)
DBMS_LOB.CLOSE(fils)

DBMS_OUTPUT.put_line('FND_LOBSFileIdCreatedis'||l_media_id)

COMMIT

Thispackageallowsusertosharefileacrossmultipleorgsorrestricttosingleorg

fnd_documents_pkg.insert_row
(x_rowid=>l_rowid,
x_document_id=>l_document_id,
x_creation_date=>SYSDATE,
x_created_by=>l_fnd_user_id,fnd_profile.value('USER_ID')
x_last_update_date=>SYSDATE,
x_last_updated_by=>l_fnd_user_id,fnd_profile.value('USER_ID')
x_last_update_login=>fnd_profile.VALUE('LOGIN_ID'),
x_datatype_id=>l_short_datatype_id,FILE
X_security_id=><securityIDdefinedinyourAttchments,UsaullySOBID/ORG_ID..>,
x_publish_flag=>'N',Thisflagallowthefiletoshareacrossmultipleorganization
x_category_id=>l_category_id,
x_security_type=>1,
x_usage_type=>'S',
x_language=>'US',
x_description=>l_filename,l_description,
x_file_name=>l_filename,
x_media_id=>l_media_id
)

commit

http://oracleappsengineering.blogspot.hk/2010/04/attachmentsapifnddocumentspkg.html 2/5
3/23/2017 OracleApplicationsTechnicalERPR11i,R12:AttachmentsAPIFND_DOCUMENTS_PKG,FND_ATTACHED_DOCUMENTS_PKG

fnd_documents_pkg.insert_tl_row
(x_document_id=>l_document_id,
x_creation_date=>SYSDATE,
x_created_by=>l_fnd_user_id,fnd_profile.VALUE('USER_ID'),
x_last_update_date=>SYSDATE,
x_last_updated_by=>l_fnd_user_id,fnd_profile.VALUE('USER_ID'),
x_last_update_login=>fnd_profile.VALUE('LOGIN_ID'),
x_language=>'US',
x_description=>l_filenamel_description
)
COMMIT
fnd_attached_documents_pkg.insert_row
(x_rowid=>l_rowid,
x_attached_document_id=>l_attached_document_id,
x_document_id=>l_document_id,
x_creation_date=>SYSDATE,
x_created_by=>l_fnd_user_id,fnd_profile.VALUE('USER_ID'),
x_last_update_date=>SYSDATE,
x_last_updated_by=>l_fnd_user_id,fnd_profile.VALUE('USER_ID'),
x_last_update_login=>fnd_profile.VALUE('LOGIN_ID'),
x_seq_num=>l_seq_num,
x_entity_name=>l_entity_name,
x_column1=>NULL,
x_pk1_value=>l_pk1_value,
x_pk2_value=>NULL,
x_pk3_value=>NULL,
x_pk4_value=>NULL,
x_pk5_value=>NULL,
x_automatically_added_flag=>'N',
x_datatype_id=>6,
x_category_id=>l_category_id,
x_security_type=>1,
X_security_id=><securityIDdefinedinyourAttchments,UsaullySOBID/ORG_ID..>,
x_publish_flag=>'Y',
x_language=>'US',
x_description=>l_filename,l_description,
x_file_name=>l_filename,
x_media_id=>l_media_id
)
COMMIT
DBMS_OUTPUT.put_line('MEDIAIDCREATEDIS'||l_media_id)
END
/

at1:24AM
Reactions: helpful (1) like (0) interesting (0)

Recommend this on Google

Labels:OracleAppsDevelopment

10comments:

Anonymous February29,2012at12:57PM
Excellent,
nevertheless,onthisexampleIwasgettingacoupleoferrors:

Ontheinsert_tl_rowbecauseamissingparameter
x_media_id=>l_media_id
Iaddedthelineandallworkedperfect

Ontheselecttogetthecategory_id,IneededtoaddtheLANGUAGE='US'becausewehave3posiblelanguages.
Thanks,thisreallyhelpusalot.

Reply

Anonymous April24,2012at6:39AM

Excellentblock.Amloadedpdffilesuccessfullytotheserver
Reply

Replies

Anonymous May30,2013at10:25AM

http://oracleappsengineering.blogspot.hk/2010/04/attachmentsapifnddocumentspkg.html 3/5
3/23/2017 OracleApplicationsTechnicalERPR11i,R12:AttachmentsAPIFND_DOCUMENTS_PKG,FND_ATTACHED_DOCUMENTS_PKG
HiitriedbutunabletoloadPDFfileintotables....

canuplzsendyourlogic..itsanurgent..yourheipwillmoreappreciatable..

Thanks,
Murali
murali4mmn@gmail.com

Reply

Anonymous April30,2012at5:40AM

Hi,itworkinginbackendbutIcan'titinEBSform.
Reply

Anonymous April30,2012at5:46AM
sorry,,itworkinginbackendbutIcan'tseeitinEBSform.

Reply

MartijnvanderKamp June1,2012at9:21AM

Igotthesameproblem.IcaninsertitviathebackendandIseerecordscreatedintheinterfacetable.Butafterquerying
inEBSitdoesnotshow.Anyonegotaclue?

Reply

Replies

Anonymous June19,2012at5:35AM

Commitagainafterexecutingthescript.Ifitdoesn'tworkonlythingicanseeisthatattachmentsetupsarenot
donecorrectly.Pleaseverifyyoursetupsandthevalueusedasprimarykey.

Reply

RayC September13,2013at3:02PM

Excellent write up. I was able to attach a PDF at the Order Line Level with small changes related to my data. Thanks
much.

Reply

Replies

ChallajayaKrishna September19,2013at5:54PM

HiAll,
IdidthesamewaybutIamgettingerrorwhilecompilingthecode.Cananyonepleasehelpme...

ERROR:"SYS.DBMS_LOB",line828ORA06512:atline100
Canyoupleaseanyoneshareyourcodetothefollowingmail...

ThanksforyourvaluableAnswersadvance..

Regards
Challa
mailid:krishna.erp11@gmail.com

Reply

SerenaDemetre July17,2015at1:45PM

DoesthisworktoattachfilestoaJournalEntryafterithasbeenposted?Thatfunctioniscurrentlynotavailableviathe
JournalformaftertheJEhasbeenposted.Wouldthisworkinstead?
Reply

Addcomment

http://oracleappsengineering.blogspot.hk/2010/04/attachmentsapifnddocumentspkg.html 4/5
3/23/2017 OracleApplicationsTechnicalERPR11i,R12:AttachmentsAPIFND_DOCUMENTS_PKG,FND_ATTACHED_DOCUMENTS_PKG

Enteryourcomment...

Commentas: Selectprofile...

Publish
Preview

NewerPost Home OlderPost

Subscribeto:PostComments(Atom)

Etherealtheme.PoweredbyBlogger.

http://oracleappsengineering.blogspot.hk/2010/04/attachmentsapifnddocumentspkg.html 5/5

Das könnte Ihnen auch gefallen