Sage X3 Import Template Processing / Script for Header and Detail

Hi 

I am trying to import a sales order using an import template, in the processing I can run some validations and stop the import by setting OK=0 if the validation fails, however it is my requirement that we just drop the one line of the import that does not pass the validation and not the entire order. Is this possible ? 

This is what I have at the moment, but the entire import fails when I set OK = 0

$ACTION
Case ACTION
When "IMPORT" : Gosub IMPORT
Endcase
Return

$IMPORT

Case IMPFIC
When "SOH"

If VALIDATION = 0 : OK = 0 : Endif

Endcase
Return

  • 0
    I have a similar requirement and am interested in the answer
  • 0 in reply to joe0507

    What I have so far is in IMPSOH --> $IMPORT

    When "SOQ", "SOP" :

    If !clalev([F:YSOQ]) Local File SORDERQ [F:YSOQ] : Endif

    Look [YSOQ]SOQ5=[M:SOH4]YCALLID(nolign);[M:SOH4]YCHGID(nolign)

    If !fstat
    GERR=1 : GMESSAGE=[M:SOH4]YCHGID(nolign)-":"-mess(1,6217,1) : OK = 0
    Endif

    I'm think it is something to do with how I am referencing the line I'm reading. I haven't done much with reading lines in code yet and am a little unsure on how to use nolign. I've tried variations on the line numbers but am not having any luck.

    Any pointers would be greatly appreciated.

  • 0 in reply to joe0507

    Have just had a little bit of success with this, but need to perform more testing...

    I put the below code against the 'Control' field action and when importing it seemed to work.

    Subprog C_YCHGID(VALEUR)
    Variable Char VALEUR()

    If !clalev([F:YSOQ]) Local File SORDERQ [F:YSOQ] : Endif
    Local Integer NOL : NOL=nolign-1
    Local Integer OK
    If VALEUR<>"" | VALEUR=[M:SOH4]YCHGID(NOL)
    #Infbox "2 check valeur and YCHGID"
    Look [YSOQ]SOQ5=[M:SOH4]YCALLID(NOL);VALEUR
    If !fstat
    OK = 0 : GERR=2:GMESSAGE=[M:SOH4]YCHGID(NOL)-":"-mess(1,6217,1)
    If OK=0 : mkstat = 2 : End : Endif
    Endif
    Endif

    End

    I imported using a file with the firs record having a duplicate value and the second record having a new record and got the below return:

    This reference already exists for this customer!

    Field YCHGID : 155320 : One Bill Import Error - Duplicate Call Charge ID - Cannot create Sales Order (S01)

    Field YCHGID(1) : 155321 : One Bill Import Error - Duplicate Call Charge ID - Cannot create Sales Order (S01)

    -------------------- Record no. 2 (Line number 4)

    This reference already exists for this customer!

    Creation of S01 4001

    1 Records created