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

ID handling the path URI #4

Open
fleischr opened this issue May 16, 2022 · 0 comments
Open

ID handling the path URI #4

fleischr opened this issue May 16, 2022 · 0 comments

Comments

@fleischr
Copy link

Passing along this info that was a little hard to come by on including keys/ids in the URI template. Figured it might be nice to make a PR to improve the overall example and save people time trying to find it elsewhere.

I recently discovered you can process keys passed in the URI (ex: SalesOrder/40001 reading the the SO with ID 40001. This can be done while attaching the root handler

lo_router->attach( iv_template = '/SalesOrder/{ID}' iv_handler_class = 'ZCL_SALESORDERHANDLER' ).

In the handler class itself you would read the ID as follows

DATA(lt_uriattributes) = mo_request->get_uri_attributes( ).
READ TABLE lt_uriattributes WITH KEY name = 'ID' ASSIGNING FIELD-SYMBOL(<fs_salesorderid>).

In this example <fs_salesorderid>-value would then contain the passed ID value.

You can include regex in iv_template as well to enforce some character restrictions/validations.

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

1 participant