«

»

Apr 09 2013

Write to or Retrieve from Media Object – Text

VN:F [1.9.22_1171]
Rating: 3.8/5 (4 votes cast)

Text MediaObject JDEMedia Objects and Imaging is a wonderful feature JD Edwards has which enables you to attach useful information to an application, including information that might currently exist as a paper-based document. Attachments which can be used are Text, Images, OLE, JDE Shortcuts, or URL’s. All these media objects are stored in F00165 table. The Text feature in the media object includes a word processor that lets you create, view, edit, and delete notes. When you create a text attachment, you can also set up templates. You can use templates to create a format for a frequently used media object. If from an application, you have Media Object Controls to be shown, or you can use System functions to Set Text, Get Text, or Edit the Media Object using the MO Datastructures (GT****) for that particular key. But all these pop up the Media Object Editor up on screen. If you do not need to show the Media object editor while saving a Text attachment or say, from a UBE; it would be not so easy. Because, the Text is stored as a BLOB in F00165. So… No direct Inserts would work. There are JDE provided API’s do do the needful here.

  1. jdeGTAddUpdate_TextKeyStr
  2. jdeGTGet_GenericTextKeyStr

AddUpdate TextKeyStr

JDERTN(JDEDB_RESULT) JDEWINAPI jdeGTAddUpdate_TextKeyStr(
PJSTR szObjectName,
PJSTR pszMOKeyStr,
LPMODATA pMOData,
long lTotalRec
);

Following would be how we would Insert a Text Attachment

WriteToMOText (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5500165 lpDS)
{
	long		lTotalRec = 0;
	int			iSequenceNum = 0;

	JDEDB_RESULT	JDBReturn = JDEDB_PASSED;
	//---------------------------------------
//Initialize Media Object Structure
	LPMODATA	pMOData = NULL;

	/* Populate the pMOData for the new record  */
	lTotalRec = 1;

	pMOData = jdeAlloc(COMMON_POOL, 255*sizeof(LPMODATA), MEM_ZEROINIT);

	pMOData->nSeq = iSequenceNum;
	pMOData->nMOType = 0;
	jdeStrcpy (pMOData->szUser, _J(" "));

	jdeStrcpy (pMOData->szItemName, lpDS->szGenericTextItemName_GTITNM);/*Name of Text Attachment - Ideally "Text1"*/
	jdeStrcpy (pMOData->szQueueName, _J(" "));
	jdeStrcpy (pMOData->szFileName, _J(" "));

	pMOData->pData = jdeAlloc(COMMON_POOL, 30001, MEM_ZEROINIT);
	jdeStrcpy (pMOData->pData, lpDS->szMediaObjectText_MOTEXT);/*Text to be written in the MO Text attachment*/

	JDBReturn = jdeGTAddUpdate_TextKeyStr(lpDS->szObjectName_OBNM, lpDS->szKey_MOTXKY, pMOData, lTotalRec);
	if (JDBReturn != JDEDB_PASSED)
	{
		jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("164F"), (LPVOID) NULL);
		return (ER_ERROR);
	}
}

RetrieveMO Text

JDERTN(JDEDB_RESULT) JDEWINAPI jdeGTGet_GenericTextKeyStr(
PJSTR szObjectName,
PJSTR pszMOKeyStr,
int nSeq,
LPMODATA pMOData,
long lTotalRec
);

This would be how we would retrieve the MO Text

RetrieveMOText (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSDD3N0011B lpDS) 
{
	long	lTotalRec = 0;
	int	iSequenceNum = 0;

	JDEDB_RESULT	JDBReturn = JDEDB_PASSED;
	LPMODATA	pMOData = NULL; //Initialize MO Data structure

	iSequenceNum = lpDS->iSequenceNumber_MOSEQN; /*Sequence would the ordinal number in MO Texts*/

	if (iSequenceNum <= 0)
 	{
 	  jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("164F"), (LPVOID) NULL);
   	  return (ER_ERROR);
	}
 	else
 	{
 	  JDBReturn = jdeGTGet_GenericTextKeyStr (lpDS->szObjectName_OBNM, lpDS->szKey_MOTXKY, iSequenceNum, &pMOData, &lTotalRec);

	  if (JDBReturn == JDEDB_PASSED)
		{
		/* Return the text to the data structure.  */
		  jdeStrcpy (lpDS->szMediaObjectText_MOTEXT, pMOData->pData);
		  jdeStrcpy (lpDS->szGenericTextItemName_GTITNM, pMOData->szItemName);
		}		
		else
		{
		  jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("0002"), (LPVOID) NULL); 
 		  return (ER_ERROR);
		}
	}
}

Attached are the sample .c, Data structure and ER code for your reference

Please register to download the attachments in Write to or Retrieve from Media Object – Text

Ref: PeopleBooks More Media_Object_8.9_APIs

Published under the license.

VN:F [1.9.22_1171]
Rating: 3.8/5 (4 votes cast)
Write to or Retrieve from Media Object - Text, 3.8 out of 5 based on 4 ratings
(Visited 4,360 times, 1 visits today)

About the author

Deepesh M Divakaran

Deepesh MD is more of a Gizmo Geek, and a techie.
A very experienced Technical Consultant on Oracle JD Edwards EnterpriseOne, and OneWorld. As a consultant he has worked for wide range of industries, from Manufacturing, Media, Oil & gas etc. and has worked on re-engineering modules, and areas of customization.
With a touch of class and understanding towards what ever he does, he is often regarded by his colleagues as the one stop answer for all Technical/Software related queries.

23 comments

Skip to comment form

  1. jerome

    Hi Deepesh,

    I’ve tried your Bsfn, the compil is OK but the pack file on server ending on error.
    Any help ?
    Thanks by advance.

    Jérôme

    VN:F [1.9.22_1171]
    Rating: -1 (from 1 vote)
    1. Deepesh M Divakaran

      Can you help me with the error? or the log?
      The API’s have been around for sometime. So I don’t think this as a tools issue either (unless you are on 8.95 or lower). You might want to check the Oracle Docs link given at the end of the article.

      Regards
      Deepesh

      VN:F [1.9.22_1171]
      Rating: +1 (from 1 vote)
  2. jerome

    I will ask the DBA to furnish me the logs.
    We are on tools 8.98
    Can you send me the URL of the Oracle’s Doc.
    Many many thanks

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  3. jerome

    Hi Deepesh,

    Here the log:

    Tue Apr 30 12:32:27 – Package build completed on server eonedev.
    Tue Apr 30 12:32:27 –
    Tue Apr 30 12:32:27 –
    Tue Apr 30 12:32:27 – Server Package build completed.
    Tue Apr 30 12:32:27 –
    Tue Apr 30 12:32:27 – ———————————————————-
    Tue Apr 30 12:32:27 –
    Tue Apr 30 15:06:22 –
    Tue Apr 30 15:06:22 – ———————————————————-
    Tue Apr 30 15:06:22 –
    Tue Apr 30 15:06:22 – Server Package Deploy Log
    Tue Apr 30 15:06:22 – Package Name: RC130430U0
    Tue Apr 30 15:06:22 – Package Description: Update Package
    Tue Apr 30 15:06:22 – Parent Package: RC120305F0
    Tue Apr 30 15:06:22 – Path Code: RC810
    Tue Apr 30 15:06:22 – Server Name: EONEDEV
    Tue Apr 30 15:06:22 – Process ID\Thread ID: 20736\21196
    Tue Apr 30 15:06:22 –
    Tue Apr 30 15:06:22 – ———————————————————-
    Tue Apr 30 15:06:22 – Initialize detail structure and working folders on server.
    Tue Apr 30 15:06:22 – Initializing internal structures for server eonedev.
    Tue Apr 30 15:06:22 – Message received from server.
    Tue Apr 30 15:06:22 – Server initialized.
    Tue Apr 30 15:06:22 – Detail server structure initialized.
    Tue Apr 30 15:06:22 –
    Tue Apr 30 15:06:22 – Setting up server eonedev for server package deploy.
    Tue Apr 30 15:06:22 – Sending lock message to server.
    Tue Apr 30 15:06:22 – Server eonedev locked and ready for package deploy.
    Tue Apr 30 15:06:22 – Deploying TAM Package to Server eonedev.
    Tue Apr 30 15:06:22 – Package deployed.
    Tue Apr 30 15:06:22 – spkgeng.c:576 PKGENG0015 ERROR: Failed to deploy the package to server EONEDEV. Error Error in file I/O.
    Tue Apr 30 15:06:22 – Correct the errors and redeploy the package.
    Tue Apr 30 15:06:22 –
    Tue Apr 30 15:06:22 – ———————————————————-

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  4. jerome

    Hello Deepesh,

    We found the problem !
    The comment for the following line is not good:

    LPMODATA pMOData = NULL; //Initialize MO Data structure

    We replacedd by:

    LPMODATA pMOData = NULL; /*Initialize MO Data structure*/

    After that, there is no error on package transfer

    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
    1. Deepesh M Divakaran

      Thanks for the update Jerome. Shall update the Docs accordingly.
      Regards
      Deepesh MD

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  5. jerome

    You’re welcome Deepesh !

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  6. Rdg

    Hi,

    We have an issue with accessing PDF files as MO from an application.
    Here is process we are using.

    Create PDFs and store in a windows network folder. We want to display those in a form of display MO from an application.
    We have tools 8.97, windows 2003, DB2 400 is the database.

    We Di not want to Go To URL, to not expose the path.

    Any help would be appreciated.

    Thanks.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    1. Deepesh M Divakaran

      Hi Rdg,

      Simplest way is to create a Media Object Queue (in F98MOQUE) using (P98MOQUE) which would point to your windows network folder.
      Secondly, while creating the Media Object attachment (PDF file name) in the F00165 table, use this Queue name in the F00165.QUNAM field. This will create the attachment linked to the record at the MO Queue location.
      Hope this helps

      Regards
      Deepesh

      VN:F [1.9.22_1171]
      Rating: 0 (from 2 votes)
  7. rdg

    Thanks Deepesh for your quick reply. I tried this but it is not able to access the files. May be a security related issue. I

    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  8. dfreeman

    Hello,
    I need to load AP check images to JDE (E910 Iseries) that are in a ‘.tif’ format. Should I use the API ‘jdeGTAddUpdate_ImageKeyStr’ to accomplish this? I’m assuming the logic would be similar to the example posted above for ‘Write To Media Object – Text’. Thanks.

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    1. Deepesh M Divakaran

      Hi dfreeman,
      Create a Media Object Queue (in F98MOQUE) using (P98MOQUE) which would point to your folder which hosts the AP check images.
      Secondly, while creating the Media Object attachment (AP Check image attachment) in the F00165 table, use this Queue name in the F00165.QUNAM field. This will create the attachment linked to the record at the MO Queue location. The File name will be stored in the GTFILENM field, and you can have appropriate MO name in the GTITNM field(which will be displayed in the left bar of the MO).

      Regards
      Deepesh MD

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  9. dfreeman

    Hello Deepesh,
    Thanks for the response. I’m currently getting the following error:” ERROR INFO JDEERR – ID= 0, Error= 164F – /OneWorld/Packages/D910UC23/source/CALLBSFN/b5500165.c, Line= 70
    Jul 26 12:23:30.209456 jdeobj.c2604 – 10911/121 WRK:Starting”. I’m not doing anything with MODATA data structure field PDATA in my C business function. Am I correct in ignoring the PDATA field when using api ‘jdeGTAddUpdate_ImageKeyStr’? Thanks.

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  10. Amar

    Hi Deepesh,

    Is there any way to insert & retrieve media object (BLOB) into custom table F5900165 ?

    Any help will be appreciated.

    Regards,
    Amar

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    1. Deepesh M Divakaran

      I’m not aware of API’s to read custom Blob fields. But, why would you copy F00165 to a custom one?

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  11. Amar

    It is customer requirement 🙁

    Regards,
    Amar

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  12. RdG

    Hi,

    I would be very interested to know if there is process to upload media files (PDF, JPEG etc) to E1. Using media objects standard feature we can upload the documents, but it shows the MO Queue and the files when it opens the file upload window.

    It would be helpful to many of us if you could provide some guidelines in this matter.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  13. Subhajit

    Hi ,

    Need a help to show multiple media object in a single form. The requirement is to show WO media object ( GT4801A ) as a media object control and Failure Media Object ( GT17767A ) in a link.

    When the appl opens , user will always see the WO media object . So I have kept it as a MO control.
    There is one more button , if user clicks on the button, a new MO viewer should open and display the corresponding Failure MO. I am using the default Media object for this.

    The issue is , the default media object is also opening in MO control that I placed for Work Order.

    If i do not have any explicit MO control , failure MO opens in a new MO Viewer window.

    Any help ??

    Regards , Subhajit

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  14. Saurabh

    Hi,

    Is there any way we can include BLOB data in our UBEs or APPLs.Is it that, a C BSFN need to be created ?(if so is this the only way to extract the data or any predefined BSFN / system function exists in 9.1 that we can use )

    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  15. SimiJoshi

    Very useful Documentation. Thanks for the info!!!

    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  16. rubensaulle

    its work!!! Thank you so much

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  17. Manish Udas

    Hello Deepesh,

    I have created one application P5617716 copied from standard application P17714 (Work Order Revision). I am getting one issue related to media object. Somehow media object is getting inserted into F00165 with F00165.TXKY = blank, and because of this that media object is getting appear for every newly created work order through this application. Can you please suggest a easiest way to fix this issue? Please visit below link for more details on issue.

    https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=554246581377161&id=2098946.1&displayIndex=1&_afrWindowMode=0&_adf.ctrl-state=lkif4e3ep_128#aref_section23

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  18. priyanka1004

    Hi Deepesh,

    Can you please tell me where to write below coding? i.e. in .C or .H?

    JDERTN(JDEDB_RESULT) JDEWINAPI jdeGTAddUpdate_TextKeyStr(
    PJSTR szObjectName,
    PJSTR pszMOKeyStr,
    LPMODATA pMOData,
    long lTotalRec
    );

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply to RdG Cancel reply