on 03-25-2024 7:41 PM
I am building a scenario in cpi where csv and pdf files are coming to CPI and being sent to receiver.
before processing the files need to be logged in CPI in original format.
Can someone please help me?
@MortenWittrock can you help please?
You can use provided logging groovy script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are many ways you can do it. However, I would like to explain about How I have done recently.
Pull or accept data from source system as Zip file. It contains Invoice csv file and PDF file both. It can contain one CSV files contains n numbers of Invoice records and their PDF files. If CSV file contains 100 invoice records, then 100 pdfs should be part of zip files.
Now let's move to details steps
1) once you have zip file, please apply-Base64 Encoder
2) save it one of the exchange property
3) Apply Base64 Decoder
4) Convert csv to xml
5) Apply iteration splitter and post the first invoice - I'm creating as an IDOC
During 5th steps - Once Invoice IDOC posted for same invoice number, use step2 property value and apply decoder and check PDF name. In this case Invoice posted - invoice number and pdf invoice name should be matched. You can use any combination of names; it is depending on invoice pdf file name. and apply SFTP same invoice to target system.
And so on.
Please let me know if you have any confusion with above steps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry > I've not mentioned about logging. you can use groovy script before first step something like below
Set this property - isPayloadLogReq as true so it will save entire zip file.
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message log01(Message message) {processData("log01",message);}
def Message log02(Message message) {processData("log02",message);}
def Message log03(Message message) {processData("log03",message);}
def Message processData(String prefix, Message message) {
//Body
def body = message.getBody(java.lang.String) as String;
//Headers
def headers = message.getHeaders();
def loggingEnabled = "false" ;
loggingEnabled = headers.get("isPayloadLogReq")
if(null != loggingEnabled && loggingEnabled.equalsIgnoreCase("true"))
{
def messagelog =messageLogFactory.getMessageLog(message)
if (messagelog != null)
{
messagelog.addAttachmentAsString(prefix,body,"text/plain")
}
}
return message;
}
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.