Skip to Content

Iterate through a Journal Entry with java

Jul 07, 2017 at 05:20 AM


avatar image

Hi everyone, hope someone can help me. I'm trying to update a user field (U_SII_Estado) in the OJDT table with the Java DI API. I works pretty well with all the entries which come from Invoices a Credit Notes, but it crashes when the TransType is 30 (JournalEntries object that represents a normal journal entry) . The error is :

5002 -- Las parametrizaciones de bloqueo de pago sólo se permiten en cuentas de interlocutor comercial [JDT1.PayBlock][line: 1]

In english, it would be something like this.

5002 -- Settings in Payment Block are only allowed in IC accounts [JDT1.PayBlock][line: 1]

I've noticed that this field in JDT, PayBlckRef is null when it comes from Invoices or Credit Notes and it is 0 when it comes from a 30 document.

I would like to check the value of that field, but I'm not able to read the child lines of the journal entry.

The code I'm using is the following:

public Map<String, Object> updateSIIEstado(List<Invoice> selectedDataList) {
        Map<String, Object> resultHashMap = new HashMap<>();
        List<Invoice> erroresInvoiceList = new ArrayList<>();
        IDocuments oDoc;
        for (Invoice invoice : selectedDataList) {
            try {
                iCompany = getICompany();
                oDoc = SBOCOMUtil.newDocuments(iCompany, SBOCOMConstants.BoObjectTypes_oJournalEntries);

              //Missing code to run througth all the lines 
                if (oDoc.update() != 0) {
                    SBOErrorMessage errMsg = iCompany.getLastError();
                    String error = errMsg.getErrorCode() + " -- " + errMsg.getErrorMessage();
            } catch (SBOCOMException e) {
                SBOErrorMessage errMsg = iCompany.getLastError();
                resultHashMap.put(TAG_RESULT, TAG_ERROR);
                resultHashMap.put(TAG_MESSAGE, "Catch:" + errMsg.getErrorMessage() + " " + errMsg.getErrorCode());
                return resultHashMap;

        resultHashMap.put(TAG_RESULTADO_ACTUALIZACION_ESTADO, getMessageResultado(erroresInvoiceList));
        resultHashMap.put(TAG_RESULT, TAG_OK);
        if (erroresInvoiceList.size() > 0) {
            resultHashMap.put(TAG_MESSAGE, String.format(CABECERA_ACTUALIZACION_FILE, erroresInvoiceList.size()));
        } else {
        return resultHashMap;

Does anybody have an idea how to achive this?

Thanks in advance for your time

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

DIEGO LOTHER Jul 09, 2017 at 05:55 PM

Hi Pedro,

I'm not familiarize with JCo, but I believe you can access the lines of Journal entries with a code like this:

JournalEntries_Lines lines = oDoc.getLines();
for (int i = 0; i < lines.getCount(); i++)
     //Then, do your logic for the line

Hope it helps.

Kind Regards,

Diego Lother

10 |10000 characters needed characters left characters exceeded