Search code examples
javaabapjcosap-erp

How to create LONGTEXTS with BAPI_QUALNOT_CREATE in SAP?


I am using BAPI_QUALNOT_CREATE in JCo to create a quality notification and it works. The only thing that does not work is the creation of LONGTEXTS.

I am using the following code:

JCoTable tblText = function.getTableParameterList().getTable("LONGTEXTS")
if (tblText == null) {
    throw new Exception("...")
}

def rowNo = 0
tblText.appendRows(meldungsTextLang.size())
for (String text : meldungsTextLang) {
    if (text != null && text.length() > 132) text = text.substring(0, 132)
    tblText.setRow(rowNo++)
    tblText.setValue("FORMAT_COL", "*")
    tblText.setValue("TEXT_LINE", text)
} 

But the text never appears in the quality notification. What is wrong with my code?


Solution

  • Objtyp and objkey are not populated in the code which are mandatory therefore try below corrected code.

    JCoTable tblText = function.getTableParameterList().getTable("LONGTEXTS")
    if (tblText == null) {
        throw new Exception("...")
    }
    
    def rowNo = 0
    tblText.appendRows(meldungsTextLang.size())
    for (String text : meldungsTextLang) {
        if (text != null && text.length() > 132) text = text.substring(0, 132)
        tblText.setRow(rowNo++)
        tblText.setValue("OBJTYP","QMSM")
        tblText.setValue("OBJKEY","1")
        tblText.setValue("FORMAT_COL", "*")
        tblText.setValue("TEXT_LINE", text)
    }