Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This operation can only be performed in stateful mode #30

Closed
hech1 opened this issue Sep 21, 2023 · 2 comments
Closed

This operation can only be performed in stateful mode #30

hech1 opened this issue Sep 21, 2023 · 2 comments

Comments

@hech1
Copy link

hech1 commented Sep 21, 2023

Hello all!

I would like to change an object using the setObjectSource method. When calling the method, I receive the following error message:

"This operation can only be performed in stateful mode".

How can I switch the mode to stateful?

Thanks,
Chris

@marcellourbani
Copy link
Owner

Sample code from unit tests (note that the creation needs to be done from a stateless client, and that you might need to specify a transport number):

    try {
      await c.createObject({
        description: "temporary test program",
        name,
        objtype: "PROG/P",
        parentName: "$TMP",
        parentPath: "/sap/bc/adt/packages/$TMP"
      })
      c.stateful = session_types.stateful
      const handle = await c.lock(path)
      // write the program
      await c.setObjectSource(main, source, handle.LOCK_HANDLE)
      // read it
      const newsource = await c.getObjectSource(main)
      expect(newsource).toMatch(/Hello,World!/m)
      // delete
      await c.deleteObject(path, handle.LOCK_HANDLE)
      await c.unLock(path, handle.LOCK_HANDLE)
    } finally {
      c.dropSession()
    }

@hech1
Copy link
Author

hech1 commented Oct 9, 2023

Thank you @marcellourbani !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants