E9.1 MO attachment append for RTF format

Rich@13

Member
Hi,

Can you please suggest how to merge two RTF or HTML formatted text attachments in JDE using a business function.

Thanks in advance!!
 
I'm not saying there isn't one, but I'm unaware of any BSFN that will do this for you.

What is your use case / issue that your are terying to solve?
 
Hi Larry,

We are doing mass update of Text type Media object attachment for multiple objects, Where we have to get the previously stored MO attachment from F00165 table and append it with the latest MO attachment text and while doing this we should also maintain the format of the text.

Thanks
 
You can use the C media object APIs to do this. Fetch the current text, allocate a buffer the size of the current text plus the size of the new text. Concat the current and new text into the buffer and then save the MO. I'm not sure how things would look if you have a mix of RTF and HTML.

Craig
 
Hi Craig,
Thanks for the reply, I have tried this approach but it's giving me plain text in the result.
Although I have passed HTML formatted MO text value to the bsfn. Also I have used GetGenericTextName API to get the previously stored text.
 
Are you passing FALSE as the last parameter? That should stop it from converting to plain text.
 
So how I've dealt this kind of stuff before (not same issue you have but close) is to build some tools in the Database.
1. A function A that converts the IMAGE data type to nVarchar(max) - cast(cast(@TXFT as varbinary(max)) as nvarchar(max))
2. Create a Stored Procedure B that converts the concatenated nvarchar(max) back to binary and updates the original F00165
3. Create a view/query Against F00165 that narrows down the data to text for the Object(s) you want to change - use Function A to convert to nvarchar(max)
4. Build a TSQL script with a Fetch Cursor Loop in it that reads the HTML text as a string, appends your new HTML Text, then calls B with the key fields and HTML string

You may need to do some trimming and add some transition HTML between the two pieces.
 
Are you passing FALSE as the last parameter? That should stop it from converting to plain text.



Hi Craig,

I am using the following code to merge the attachments. But it's converting the stored HTML attachment to plain text.



/* An existing attachment exists, concatenate the new text */
pNewText = (PJSTR) jdeAlloc(COMMON_POOL, ( jdeStrlen(lpDS->szMediaObjectText) + jdeStrlen(pText) + 8) * sizeof(JCHAR),MEM_ZEROINIT );
jdeSprintf(pNewText, _J("%ls%ls\n"), lpDS->szMediaObjectText, pText);
}

/* Update the attachment for the invoice */
if (ModifyGenericTextName(_J("GT4801"), &dsGT4801, pNewText) != JDEDB_PASSED)
{
lpDS->cERRORFlag= _J('1');
}
 
Rich, I suspect that the jdeSprintf() is internally extracting the plain text from the HTML. Perhaps using jdeStrncat() instead of jdeSprintf() would work fot you, like this:
pNewText = (PJSTR) jdeAlloc(COMMON_POOL, ( jdeStrlen(lpDS->szMediaObjectText) + jdeStrlen(pText) + 8) * sizeof(JCHAR),MEM_ZEROINIT );
jdeStrncpy(pNewText, lpDS->szMediaObjectText, DIM(pNewText))
jdeStrncat(pNewText, pText, DIM(pText));
 
Hi Craig,

I am using the following code to merge the attachments. But it's converting the stored HTML attachment to plain text.



/* An existing attachment exists, concatenate the new text */
pNewText = (PJSTR) jdeAlloc(COMMON_POOL, ( jdeStrlen(lpDS->szMediaObjectText) + jdeStrlen(pText) + 8) * sizeof(JCHAR),MEM_ZEROINIT );
jdeSprintf(pNewText, _J("%ls%ls\n"), lpDS->szMediaObjectText, pText);
}

/* Update the attachment for the invoice */
if (ModifyGenericTextName(_J("GT4801"), &dsGT4801, pNewText) != JDEDB_PASSED)
{
lpDS->cERRORFlag= _J('1');
}

Where is the code to retrieve the existing attachment?
 
The last parameter, set to TRUE, will convert the MO to plain text. Try setting it to FALSE.

Thanks Craig, It's working now.
It's creating some extra space between the text , Can you please suggest how to remove that extra lines between the text.
 
Thanks Craig, It's working now.
It's creating some extra space between the text , Can you please suggest how to remove that extra lines between the text.

Actually the JDE Media Object routines have a tendency to create those trailing spaces (and sometimes more). Users may also create blank lines at the end.
 
Back
Top