Skip to Content
avatar image
Former Member

Iterate through a Journal Entry with java

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;
        connect();
        for (Invoice invoice : selectedDataList) {
            try {
                iCompany = getICompany();
                oDoc = SBOCOMUtil.newDocuments(iCompany, SBOCOMConstants.BoObjectTypes_oJournalEntries);
                oDoc.getByKey(Integer.valueOf(invoice.getDocEntry()));


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


        disconnect();
        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 {
            resultHashMap.put(TAG_MESSAGE, ACTUALIZACION_SII_ESTADO_SAP_SUCCESS);
        }
        return resultHashMap;
    }

Does anybody have an idea how to achive this?

Thanks in advance for your time

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • 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++)
    {
         lines.setCurrentLine(i);
         //Then, do your logic for the line
    }

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded