Calling Object from Code

SUGGESTED

Does anybody have any information or examples of calling an X3 object from another process within X3?  I don't want to display the object window, I want to open the object in code, populate the screen values dynamically in the code, and then call the CREATE action.

Parents
  • 0
    SUGGESTED

    Hi Denise:

    Maybe this example would help you, this answer is also avaialble in oursageplace website avaialble for partners, here

    example with ITC object. Table ITMCOST WITH KEY = STOFCY+ITMREF+CSTTYP-ITCSEQ+UID

         Local File ITMCOST [ITC]

         CLE_COUT(0) = [M:ITF0]STOFCY

         CLE_COUT(1) = "1" : # cost type

         CLE_COUT(2) = num$(year(date$)) : # year

         CLE_COUT(3) = "0" : # Sequence no.

         CLE_ART     = [M:ITF0]ITMREF

         Call OBJET("ITC",CLE_ART,CLE_COUT) From GOBJET

  • 0 in reply to Esfahani
    Hey,

    I'm also interested in this topic. The code Ali posted opens a screen when I run it. Is there some way to create an object without opening a screen?

    Thanks in advance,
    Jason
  • 0 in reply to JFrank
    import template
  • 0 in reply to Barak
    Hello again, Barak!

    We currently have some custom code that uses an import template in the code but we're finding that it can't keep up with the volume we need. We have to be able to create 20K - 30K shipments in X3 per day. With the import template, we haven't been able to get over 10K.

    This is related to my other forum thread. While I had some early success with your advice (I think I accepted your answer), there are some corner cases I can't seem to handle.

    The web service solution: I can't get the invoicing elements to update and it wants me to pass in all the customer information for those screens.

    FUNAUTDLV: doesn't give me the granularity I need (we partially ship line items sometimes) and non-stock managed items automatically ship. I was trying to use allocation as my control, but these don't allocate.

    I'm still actively trying to find a work around for both of these approaches but I'm also wondering if there's some way I can just build the whole shipment in my custom script.

    Thanks,
    Jason
  • 0 in reply to JFrank
    Hi Jason

    1. just wondering , if you used import template to create deliveries, what happens after 10K? as each import template creates one shipment it does not suppose to fail...

    2. as I said before web service to create deliveries is not a good idea, it will not do what you want and also it is much slower than import template and less reliable.

    3.FUNAUTDLV - my knowledge about allocations is poor. however FUNAUTALL should give you the ability to do what you need. but I don't really know the details...
  • 0 in reply to Barak
    Hey,

    1. The imports don't stop at 10K, they are so slow that it takes 24 hours for 10K to process. We have a bit of custom code that reads out of a table, writes the file, then imports it. I did some profiling in the custom code and saw that the import was taking all the time. Additionally, we tried running multiple import files at the same time and the imports didn't speed up at all.

    2. Our other web services perform very well. We have multiple pools for the most busy ones. The web service calls we make for integration with our LOB are able to keep up. Only the custom code that uses the importer can't keep up. I'm close to getting the web service working. I'm able to move the invoicing elements from the order to the shipment now. The last thing I need to do is get the address stuff to populate the ADB2 and ADB3 screens.

    3. FUNAUTALL doesn't let you set the quantity on an allocation. FUNMANALL does allow you to, but I can't get it to work from script.

    Thanks for all the help!
  • 0 in reply to JFrank

    1+2 .
    that makes it 8 sec per delivery which is slow but make sense, but even if it was faster is not good enough for you. it seems that X3 is not a good solution for you...

    I think the importer is not the one that takes the time, it is the time to create the delivery as part of the importer.
    the web service will take the same time.

    from my experience web service is much slower than import template and after 40 sec of running will fail.
    did you compare the creation time of one delivery using import template to the creation time using web service?

    do you use importer inside a code that is actually runs as web service? if so , it does not make sense to me.

    BTW , from my experience running import template parallel can cause miss much in the data.

    3. here is a code to run FUNAUTDLV from code , try to use the same way to run FUNMANALL , but you will need to figure out the parameters - VALPAR and figure out what you want to do....
    however it will probably be the same time to create 10k deliveries...
    hope it will help

    you can use this to create a delivery, from a sales order
    subprog CRE_SDH(ASTOFCY, ASOHNUM,ASDHNUM)
    value char ASTOFCY #stock site
    value char ASOHNUM
    variable char ASDHNUM

    Local Integer WZGSERVEUR
    Local Char VALEUR(250)
    Local Char VALPAR(250)(1..20)
    Local Char WSAVFNC


    #keep GFONCTION
    WSAVFNC = GFONCTION
    GFONCTION = "FUNAUTDLV"


    #indicate that is not web service
    WZGSERVEUR = GSERVEUR
    GSERVEUR = 1

    VALPAR(1) = ASTOFCY
    VALPAR(2) = ASOHNUM


    #running the function
    Call TRAITE_CHAR(VALEUR,VALPAR,"","FUNAUTDLV","DAUTDLV",4,"SPEZAUTDLV") From GTRAITE


    #restore back the original values
    GFONCTION = WSAVFNC
    GSERVEUR = WZGSERVEUR
    end


    #code for SPEZAUTDLV - it fills the DIA screen with data, DIA (DMANALL) is the criteria window for #FUNMANALL and also for FUNAUTDLV (same abbriviation)
    #and then runs the standard X3 process

    #you need to do the same and add the name of your file as the last parmater in TRAITE_CHAR

    ACTION
    Case ACTION
    When "EXEC" : Gosub EXEC
    When Default
    Endcase
    Return


    $EXEC
    If GSERVEUR
    Raz [M:DIA]
    [M:DIA]STOFCY = PARAM(1)
    [M:DIA]SOHNUMDEB = PARAM(2)
    [M:DIA]SOHNUMFIN = PARAM(2)
    Call GETSOC ([M:DIA]STOFCY) From DEVSUB
    [M:DIA]CPY = GSOCIETE
    [M:DIA]TYPPRO = 1
    [M:DIA]SHIDAT = date$+365
    [M:DIA]DRNFLG = 1
    [M:DIA]DRN = 0
    [M:DIA]ABT = 1
    Endif

    Gosub EXEC_TRTAUTDLV From FUNAUTDLV

    If GOK=1
    If [F:SDH]SDHNUM<>""
    ASDHNUM = [F:SDH]SDHNUM
    Endif
    Endif

    GPE = 1
    Return

Reply
  • 0 in reply to JFrank

    1+2 .
    that makes it 8 sec per delivery which is slow but make sense, but even if it was faster is not good enough for you. it seems that X3 is not a good solution for you...

    I think the importer is not the one that takes the time, it is the time to create the delivery as part of the importer.
    the web service will take the same time.

    from my experience web service is much slower than import template and after 40 sec of running will fail.
    did you compare the creation time of one delivery using import template to the creation time using web service?

    do you use importer inside a code that is actually runs as web service? if so , it does not make sense to me.

    BTW , from my experience running import template parallel can cause miss much in the data.

    3. here is a code to run FUNAUTDLV from code , try to use the same way to run FUNMANALL , but you will need to figure out the parameters - VALPAR and figure out what you want to do....
    however it will probably be the same time to create 10k deliveries...
    hope it will help

    you can use this to create a delivery, from a sales order
    subprog CRE_SDH(ASTOFCY, ASOHNUM,ASDHNUM)
    value char ASTOFCY #stock site
    value char ASOHNUM
    variable char ASDHNUM

    Local Integer WZGSERVEUR
    Local Char VALEUR(250)
    Local Char VALPAR(250)(1..20)
    Local Char WSAVFNC


    #keep GFONCTION
    WSAVFNC = GFONCTION
    GFONCTION = "FUNAUTDLV"


    #indicate that is not web service
    WZGSERVEUR = GSERVEUR
    GSERVEUR = 1

    VALPAR(1) = ASTOFCY
    VALPAR(2) = ASOHNUM


    #running the function
    Call TRAITE_CHAR(VALEUR,VALPAR,"","FUNAUTDLV","DAUTDLV",4,"SPEZAUTDLV") From GTRAITE


    #restore back the original values
    GFONCTION = WSAVFNC
    GSERVEUR = WZGSERVEUR
    end


    #code for SPEZAUTDLV - it fills the DIA screen with data, DIA (DMANALL) is the criteria window for #FUNMANALL and also for FUNAUTDLV (same abbriviation)
    #and then runs the standard X3 process

    #you need to do the same and add the name of your file as the last parmater in TRAITE_CHAR

    ACTION
    Case ACTION
    When "EXEC" : Gosub EXEC
    When Default
    Endcase
    Return


    $EXEC
    If GSERVEUR
    Raz [M:DIA]
    [M:DIA]STOFCY = PARAM(1)
    [M:DIA]SOHNUMDEB = PARAM(2)
    [M:DIA]SOHNUMFIN = PARAM(2)
    Call GETSOC ([M:DIA]STOFCY) From DEVSUB
    [M:DIA]CPY = GSOCIETE
    [M:DIA]TYPPRO = 1
    [M:DIA]SHIDAT = date$+365
    [M:DIA]DRNFLG = 1
    [M:DIA]DRN = 0
    [M:DIA]ABT = 1
    Endif

    Gosub EXEC_TRTAUTDLV From FUNAUTDLV

    If GOK=1
    If [F:SDH]SDHNUM<>""
    ASDHNUM = [F:SDH]SDHNUM
    Endif
    Endif

    GPE = 1
    Return

Children
  • 0 in reply to Barak
    I apologize for resurrecting what appears to be a dead topic but I also have a question similar to the above. Specifically I am finding it troubling that I cannot tell X3 to CLOSE an order upon a delivery even if it is only a partial delivery.

    My sage reseller has flatly stated this is not possible -- Given the quantity of orders we process, I am unable to accept this, so I need to find some kind of programmatic solution.

    I would effectively like to execute the logic behind the "close" button on the sales order screen silently / no popup screens etc.

    I am able to call OJBET_CHAR to load the sales order (but this creates a visible screen), and I added code into SPESOH to call EXEBOUT, trying to simulate closing the order but this also pops up the prompt asking for the closing reason..

    Any help would be appreciated.