Skip to Content
author's profile photo Former Member
Former Member

Reading BusinessObject's key values in the task

Hi,

I have a object in my container which is of type BUS2081.

I need to read its key values(InvoiceDocNumber, FiscalYear) in my task method for further processings.

I have found these macros swc_get_object_type, swc_get_object_key. But not getting how could i use these for my scenario.

Could anybody explain how can i achieve this ?

Regards,

Anbarasan K

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 03:06 PM

    Hi Anbarasan,

    1.Declaring the variable Object as an object reference with type SWC_OBJECT

    Call: DATA <Object> TYPE SWC_OBJECT.

    The variable <Object> declared holds the object reference in the form of an "object handle", that is, in a runtime structure that only exists within a program context.

    But containers passed via a function module interface always contain persistent object references. Before you read an object reference from a container and store it in the variable <Object> , you must make all object references in the container into handles. The macro SWC_CONTAINER_TO_RUNTIME does this for you.

    This note only applies to you if:

    o You read a role parameter container for role resolution.

    o You read an event parameter container within a check function module or a receiver type function module.

    If you are within the object type program, the container does not have to be converted.

    2.Reading an object reference from a container

    Call: SWC_GET_ELEMENT <Container> <Element> <Object>.

    Container describes a container instance created with the macro instruction SWC_CONTAINER .

    Element is the ID of the container element, under which the object reference was stored.

    Object is the object reference declared with TYPE SWC_OBJECT .

    3.Separating the object type-specific key from the object reference:

    Call: SWC_GET_OBJECT_KEY <Object> <ObjectKey>.

    4.Separating the ID of the object type from the object reference:

    Call: SWC_GET_OBJECT_TYPE <Object> <ObjectType>.

    Object type is the ID of the object type and is declared with

    DATA <Object type> LIKE SWOTOBJID-OBJTYPE.

    By

    Pari

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Pari & Pavan.

      I got it with the following code.

      DATA: l_bus2081 TYPE swc_object,

      l_bus2081key TYPE swotobjid-objkey.

      swc_get_element container 'InvDocObject' l_bus2081.

      swc_get_object_key l_bus2081 l_bus2081key.

      L_BELNR = l_bus2081key+0(10). "InvoiceDocNumber

      L_GJAHR = l_bus2081key+10. "FiscalYear

      Thank you.

      Regards,

      Anbarasan K

  • Posted on Dec 19, 2008 at 03:02 PM

    No, the macros right one you have to use is

    • SWC_SET_ELEMENT conatiner <name> <value>

    • SWC_SET_TABLE conatiner <Name> <value>.

    In your case you have to use SWC_SET_ELEMENT this will pass the values from BO--to task container

    make sure that you make the task conatiner elements as Import Export Enabled.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 03:23 PM

    Hi Anbarasan,

    In order to retrieve the Key Values (Invoice Doc # and Fiscal Year), you need to use the below fields in your code:

    "object-key-invoicedocnumber" for Invoice Doc #

    "object-key-fiscalyear" for Fiscal Year.

    e.g., if you want to concatenate the Invoice Doc # and Fiscal year into one variable, you will write the following piece of code:

    concatenate object-key-invoicedocnumber object-key-fiscalyear into varialbe1.

    Hope this helps.

    Regards,

    anwar.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.