機械翻訳について

添付の拡張

オーダー管理拡張を使用して、添付を作成、読取り、更新または削除します。

概要

テキストまたはXML添付ファイルを使用します。 バイナリ・ファイルを使用しないでください。

テキストまたはXML添付ファイルを使用するコード

ノート

  1. getメソッドを使用して、添付ファイルに含まれるすべてのテキストを取得するgetTextなど、すでに存在する添付から添付の詳細を取得します。getPklValueを使用して、添付を参照する販売オーダーまたはオーダー明細を取得し、getFileNameを使用して添付ファイル名の名前を取得します。 使用できるメソッドのいくつかを次に示します。

    • getText

    • getPklValue

    • getEntityName

    • getDataTypeCode

    • getTitle

    • getDescription

    • getFileName

    • getUrl

    • getCategoryName

  2. createAttachmentメソッドを使用してアタッチメントを作成し、setメソッドを使用してアタッチメントの作成方法を指定します。 ファイル、テキストまたはURLタイプの新しい添付ファイルを指定できます。 たとえば、setFileNameを使用して、添付ファイルの名前を指定します。 使用できるメソッドのいくつかを次に示します。

    • setDataTypeCode

    • setTitle

    • setDescription

    • setFileName

    • setFileContentType

    • setFileContent

  3. 添付を削除するには、deleteAttachmentメソッドを使用します。 この例では、コードでfor文を使用して、販売オーダーに含まれるすべての添付を反復処理し、そのすべてを削除します。

オーダー・ヘッダーからの添付の取得

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
import oracle.apps.scm.doo.common.extensions.Attachment;
import oracle.jbo.domain.BlobDomain;

String poNumber = header.getAttribute("CustomerPONumber");
if (poNumber == null) return;
if (!poNumber.startsWith("PMC TEST")) return;

List < Message > messages = new ArrayList < Message > ();
//messages.add(new Message( Message.MessageType.ERROR, "HeaderId: " + header.getAttribute("HeaderId")));


/////////////////Read header attachments
def attachments = header.getAttachments();
for (int i = 0; i < attachments.size(); ++i) {
    def attachment = attachments[i];
    messages.add(new Message(Message.MessageType.ERROR, "Pk1value:" + attachment.getPk1Value()));
    messages.add(new Message(Message.MessageType.ERROR, "Entityname:" + attachment.getEntityName()));
    messages.add(new Message(Message.MessageType.ERROR, "DatatypeCode:" + attachment.getDatatypeCode()));
    messages.add(new Message(Message.MessageType.ERROR, "Title:" + attachment.getTitle()));
    messages.add(new Message(Message.MessageType.ERROR, "Description:" + attachment.getDescription()));
    messages.add(new Message(Message.MessageType.ERROR, "FileName:" + attachment.getFileName()));
    messages.add(new Message(Message.MessageType.ERROR, "File Content Type:" + attachment.getFileContentType()));
    def blobDomainData = attachment.getFileContent();
    messages.add(new Message(Message.MessageType.ERROR, "File Content:" + blobDomainData.toString()));
    messages.add(new Message(Message.MessageType.ERROR, "Url:" + attachment.getUrl()));
    messages.add(new Message(Message.MessageType.ERROR, "Text:" + attachment.getText()));
}

ValidationException ex = new ValidationException(messages);
throw ex;

オーダー明細からの添付の取得

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;

String poNumber = header.getAttribute("CustomerPONumber");
if (poNumber == null) return;
if (!poNumber.startsWith("PMC TEST")) return;

List < Message > messages = new ArrayList < Message > ();
//messages.add(new Message( Message.MessageType.ERROR, "Enter Attachment On Save"));
//messages.add(new Message( Message.MessageType.ERROR, "CustomerPONumber: " + poNumber));
Long headerId = header.getAttribute("HeaderId");
messages.add(new Message(Message.MessageType.ERROR, "HeaderId: " + headerId));

def lines = header.getAttribute("Lines");

while (lines.hasNext()) {

    def line = lines.next();
    def attachments = line.getAttachments();

    for (int i = 0; i < attachments.size(); ++i) {
        def attachment = attachments[i];
        messages.add(new Message(Message.MessageType.ERROR, "Pk1value:" + attachment.getPk1Value()));
        messages.add(new Message(Message.MessageType.ERROR, "Entityname:" + attachment.getEntityName()));
        messages.add(new Message(Message.MessageType.ERROR, "DatatypeCode:" + attachment.getDatatypeCode()));
        messages.add(new Message(Message.MessageType.ERROR, "Text:" + attachment.getText()));
        messages.add(new Message(Message.MessageType.ERROR, "Title:" + attachment.getTitle()));
        messages.add(new Message(Message.MessageType.ERROR, "Description:" + attachment.getDescription()));
        messages.add(new Message(Message.MessageType.ERROR, "FileName:" + attachment.getFileName()));
        messages.add(new Message(Message.MessageType.ERROR, "Url:" + attachment.getUrl()));
        messages.add(new Message(Message.MessageType.ERROR, "Url:" + attachment.getCategoryName()));
    }
}
ValidationException ex = new ValidationException(messages);
throw ex;

オーダー・ヘッダーへの添付の追加

この例では、オーダー・ヘッダーに添付を追加します。

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
import oracle.apps.scm.doo.common.extensions.Attachment;
import oracle.jbo.domain.BlobDomain;
String poNumber = header.getAttribute("CustomerPONumber");
if (poNumber == null) return;
if (!poNumber.startsWith("WriteAttachmentsHeaderOnEndSubmit_run_extension")) return;

List < Message > messages = new ArrayList < Message > ();
//messages.add(new Message( Message.MessageType.ERROR, "HeaderId: " + header.getAttribute("HeaderId")));

////create header attachments
//Create TEXT attachment
Attachment newAttachment1 = new Attachment();
newAttachment1.setDatatypeCode("TEXT");
newAttachment1.setTitle("This is a text type title on submit");
newAttachment1.setText("this is some text");
newAttachment1.setDescription("this is some description");
header.createAttachment(newAttachment1);

//Create URL attachment
Attachment newAttachment2 = new Attachment();
newAttachment2.setDatatypeCode("WEB_PAGE");
newAttachment2.setTitle("This URL points to google server on submit");
newAttachment2.setUrl("http://www.google.com/");
newAttachment2.setDescription("Used for searching stuffs");
header.createAttachment(newAttachment2);

//Create a file attachment
Attachment newAttachment3 = new Attachment();
newAttachment3.setDatatypeCode("FILE");
newAttachment3.setTitle("file type title");
newAttachment3.setDescription("this file contains some random data on submit");
newAttachment3.setFileName("APITextFile.txt");
//newAttachment3.setFileContentType("application/text");
newAttachment3.setFileContentType("text/plain");
//newAttachment3.setFileContent(new BlobDomain("This is a test creation using Bytes".getBytes()));
newAttachment3.setFileContent("This is a test for creation file from api using bytes".getBytes());
header.createAttachment(newAttachment3);

/*delete all header attachments
//messages.add(new Message( Message.MessageType.ERROR, "Delete all header attachments"));
def attachments1 = header.getAttachments();
for (int i; i< attachments1.size(); ++i) {
def attachment1 = attachments1[i];
//header.deleteAttachment(attachment1);
}*/

ValidationException ex = new ValidationException(messages);
throw ex;

オーダー・ヘッダーからの添付の削除

この例では、オーダー・ヘッダーから添付を削除します。

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
import oracle.apps.scm.doo.common.extensions.Attachment;
import oracle.jbo.domain.BlobDomain;

String poNumber = header.getAttribute("CustomerPONumber");
if (poNumber == null) return;
if (!poNumber.startsWith("DeleteAttachmentsHeaderOnSubmit_run_extension")) return;

//delete all header attachments
//messages.add(new Message( Message.MessageType.ERROR, "Delete all header attachments"));
def attachments1 = header.getAttachments();

for (int i; i < attachments1.size(); ++i) {
    //throw new ValidationException("An order with the Purchase Order  ddddd  Number " +  attachments1 + " already exists.");
    def attachment1 = attachments1[i];
    header.deleteAttachment(attachment1);
}

オーダー明細に添付を追加

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
import oracle.apps.scm.doo.common.extensions.Attachment;
import oracle.jbo.domain.BlobDomain;

String poNumber = header.getAttribute("CustomerPONumber");
if (poNumber == null) return;
if (!poNumber.startsWith("WriteAttachmentsLineOnEndSubmitOnly_run_extension")) return;

List < Message > messages = new ArrayList < Message > ();
//messages.add(new Message( Message.MessageType.ERROR, "HeaderId: " + header.getAttribute("HeaderId")));
def lines = header.getAttribute("Lines");

while (lines.hasNext()) {

    def line = lines.next();

    /////////////////create header attachments
    //Create TEXT attachment
    Attachment newAttachment1 = new Attachment();
    newAttachment1.setDatatypeCode("TEXT");
    newAttachment1.setTitle("This is a text type title");
    newAttachment1.setText("this is some text");
    newAttachment1.setDescription("this is some description");

    line.createAttachment(newAttachment1);

    //Create URL attachment
    Attachment newAttachment2 = new Attachment();
    newAttachment2.setDatatypeCode("WEB_PAGE");
    newAttachment2.setTitle("This URL points to google server");
    newAttachment2.setUrl("http://www.google.com/");
    newAttachment2.setDescription("Used for searching stuffs");
    line.createAttachment(newAttachment2);

    //Create a file attachment
    Attachment newAttachment3 = new Attachment();
    newAttachment3.setDatatypeCode("FILE");
    newAttachment3.setTitle("file type title");
    newAttachment3.setDescription("this file contains some random data");
    newAttachment3.setFileName("APITextFile.txt");
    //newAttachment3.setFileContentType("application/text");
    newAttachment3.setFileContentType("text/plain");
    //newAttachment3.setFileContent(new BlobDomain("This is a test creation using Bytes".getBytes()));
    newAttachment3.setFileContent("This is a test for creation file from api using bytes".getBytes());
    line.createAttachment(newAttachment3);

}
/*delete all header attachments
//messages.add(new Message( Message.MessageType.ERROR, "Delete all header attachments"));
def attachments1 = header.getAttachments();
for (int i; i< attachments1.size(); ++i) {
  def attachment1 = attachments1[i];
  //header.deleteAttachment(attachment1);
}*/

ValidationException ex = new ValidationException(messages);
throw ex;  

オーダー明細からの添付の削除

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
import oracle.apps.scm.doo.common.extensions.Attachment;
import oracle.jbo.domain.BlobDomain;
String poNumber = header.getAttribute("CustomerPONumber");
if (poNumber == null) return;
if (!poNumber.startsWith("DeleteAttachmentsLineOnSubmitOnly_run_extension")) return;

List < Message > messages = new ArrayList < Message > ();
//messages.add(new Message( Message.MessageType.ERROR, "HeaderId: " + header.getAttribute("HeaderId")));
def lines = header.getAttribute("Lines");

while (lines.hasNext()) {

    def line = lines.next();

    //delete all attachments from the order header 
    //messages.add(new Message( Message.MessageType.ERROR, "Delete all header attachments"));
    def attachments1 = line.getAttachments();
    for (int i; i < attachments1.size(); ++i) {
        def attachment1 = attachments1[i];
        line.deleteAttachment(attachment1);
    }

}