Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Restriction when using Business object

WeijiaSun
Advisor
Advisor
0 Likes
884

hi all,

Currently i want to use Business Object to create a new Company code. After searching the Business object in Transaction SWO1, I find 'BUS0002' can realize it. But there is only one import parameter of method 'create' , that's the company code key id.

Is there any solution to import other parameters,such as description of the company code, currency etc. when using the business object to create the company code?

Thanks in advance.

Vivi

4 REPLIES 4
Read only

aakash_neelaperumal2
Active Participant
0 Likes
805

yes you can add that to your method...just click on the parameters for the method

Read only

Former Member
0 Likes
805

Hi,

All the fields you are talking about are in BUS0002.

If you see the method 'create' of this business object, you have to pass "Object key" here. Object key is not only the company code. This is concatenation of fields required for creating company code. These fields are.

Fields	Data type      Length	Description
-----   -----------   --------    -----------------
BUKRS	CHAR		4	Company Code
BUTXT	CHAR		25	Name of the company code or company
ORT01	CHAR		25	City
LAND1	CHAR		3	Country key
WAERS	CUKY		5	Currency Key
SPRAS	LANG		1	Language key

Just define a structure with this field, assing the values and then pass it to 'object key'. See below.

DATA: BEGIN OF objectkey,
       bukrs LIKE t001-bukrs,
       butxt LIKE t001-butxt,
       ort01 LIKE t001-ort01,
       land1 LIKE t001-land1,
       waers LIKE t001-waers,
       spras LIKE t001-spras,
     END OF objectkey.

objectkey-bukrs = '2010'.
objectkey-butxt = 'My company code description'.
objectkey-ort01 = 'NEW YORK'.
objectkey-land1 = 'US'.
objectkey-waers = 'USD'.
objectkey-spras = 'E'.

*" When you use object BUS0002, assing this structure OBJECTKEY to field
*" OBJECTKEY of  'CREATE' method

Let me know if you need any other information.

Regards,

RS

Read only

0 Likes
805

hi RS

just writes a test program :

DATA: BEGIN OF objectkey,

bukrs LIKE t001-bukrs,

butxt LIKE t001-butxt,

ort01 LIKE t001-ort01,

land1 LIKE t001-land1,

waers LIKE t001-waers,

spras LIKE t001-spras,

END OF objectkey.

objectkey-bukrs = '2010'.

objectkey-butxt = 'My company code description'.

objectkey-ort01 = 'NEW YORK'.

objectkey-land1 = 'US'.

objectkey-waers = 'USD'.

objectkey-spras = 'EN'.

swc_container container.

lv_object_type = 'BUS0002'.

swc_create_object obj lv_object_type ''.

swc_create_container container.

swc_set_element container 'objectkey' objectkey.

swc_set_element container 'CORR_NUMBER' 'EB2K900952'.

swc_set_element container 'SUPPRESSDIALOG' ' '.

swc_call_method obj 'Create' container.

At runtime session, there is no value transfered to the maintainence view except the company code id.

When i go through the program of 'create' method,

i found that:

  • Call maintenance of CompanyCodeId

CLEAR V_T001.

V_T001-MANDT = SY-MANDT.

V_T001-BUKRS = OBJECT-KEY-COMPANYCODEID.

CALL FUNCTION 'VIEW_MAINTENANCE_SINGLE_ENTRY'

EXPORTING

ACTION = 'INS '

CORR_NUMBER = CORR_NUMBER

VIEW_NAME = 'V_T001'

SUPPRESSDIALOG = SUPPRESSDIALOG

INSERT_KEY_NOT_FIXED = INSERT_KEY_NOT_FIX

IMPORTING

CORR_NUMBER = CORR_NUMBER

CHANGING

ENTRY = V_T001.

so i guess, it should be enhanced some coding here, something like

V_T001-BUTXT = OBJECT-KEY-description ?

but i am not sure about it.

What do you think about it?

Thanks again for your kindly help.

Regards

Vivi

Message was edited by:

Vivi Sun

Read only

WeijiaSun
Advisor
Advisor
0 Likes
805

Hi Aakash,

Thanks a lot for your reply!

Is that means i should inherit the standard Business object to a new Z-object, afterwards, add some new parameters and coding to the 'create' method?

Best Regards

Vivi