Application Development 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: 

Example of correct BAPI_BUS1077_CREATE call

Former Member
0 Kudos

Hi!

Does anybody know how to create a hazard calling this bapi ? I've tried several combinations but it always returns me several errors, for example, not enough parameters, required fields not filled,...

If anybody could give me an example of its call (e.g. for the first level) i would appreciate it so much.

Thanks!!

Regards,

Diana.

4 REPLIES 4

Former Member
0 Kudos

Have you tried "where used"

Rob

0 Kudos

Yes, I've tried, but i didn't find any helpful result... there were only two matches (one for modifying a substance and the other was a call from another function module that i wasn't able to run either)

Any other suggestion?

Thanks!

Regards,

Diana.

0 Kudos

*&----


*

*& Report RC1_1077_BAPI_EXAMPLE_CHANGE

*&

*&----


*

*&

*& On the one hand, this Report is an automatic test for the BAPI- functions.

*& It performs different methods to create, edit and delete specifications and

*& shows on a list, if any errors occured by performing the BAPI-functions.

*&

*& On the other hand, this report can be used as reference-code and tutorial for using

*& the BAPI-functions.

*&

*&

*& The here tested BAPI-functions are:

*&

*& Function Short description

*&

*& BAPI_BUS1077_CREATE Creates a new specification or a property of an existing one

*& BAPI_BUS1077_CHANGE Changes properties of an existing specification

*& BAPI_BUS1077_DELETE Deletes a specification or single properties

*& BAPI_TRANSACTION_COMMIT Commits the work

*& BAPI_BUS1077_SAVEFROMBUFFER Clears locks and saves data from buffer to dictionary

*& BAPI_BUS1077_GETDETAIL Reads properties of existing specifications

*&

*&

*& The following methods are relevant for you, if you need some information how to use

*& these functions(detailed information about methods in their definitions):

*&

*& Method Short description Used BAPI- functions

*&

*& class_setup Creates the two Test- specifications BAPI_BUS1077_CREATE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& class_teardown Deletes the two Test- specifications BAPI_BUS1077_DELETE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_subheader Changes data in the substance-header BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_comp Changes the first component in the property BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_ident Changes the first identifier of a specification BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_ident_usage Changes the identifier usage of a specification BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_prop_ftext Changes the property ftext & longtext of a specification BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_prop_usage Changes the first property usage of a specification BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_ident_longtext Changes the identifier longtext of a specification BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_read_usage_filter Assures that the usage filter is working properly BAPI_BUS1077_GETDETAIL

*& test_ref_subs Assure that specification referencescan be created BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CREATE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_comp Changes the first component in a property BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_assessment Changes the assessment of a value assignment BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_change_prop_data Changes the property data of a value assignment BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_CHANGE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*& test_del_ref Deletes all references of a specification BAPI_BUS1077_GETDETAIL; BAPI_BUS1077_DELETE; BAPI_TRANSACTION_COMMIT; BAPI_BUS1077_SAVEFROMBUFFER

*&

*&

*& The following methods are "help- methods" with different functionalities:

*&

*& Method Short Description

*&

*& set_dis_tab Adds one row the the displayed error-table

*& get_dis_tab Gets an error-table

*& set_dis_wa Fills one row of an error-table

*& set_dis_wa Gets one row of an error-table

*& get_random_matnr Gets a random matnr from dictionary

*& get_random_source Gets a random source from dictionary

*& get_random_phrase Gets a random source from dictionary (from given phrase selection set)

*& write_table_to_list Writes one table to display to list

*&

*&

*& Important variables:

*&

*& Variable Short Description

*&

*& l_return_tab Table for the errors to occure in BAPI-functions

*& l_dis_tab Error-table with data to display

*& Fields: function, function-description, error-description, edited specification

*& l_spec_key ID of the edited specification.

*&

*&

*&----


*

*&----


*

*&

*& !!! helpfull technical information for BAPI usage !!!

*& Use F1-help for additional information.

*&

*&----


*

*

  • The field "format_flag" in table "bapi1077df" exists not in every system

  • if the field doent exist, just delete the lines wich specify this data

*

*

  • BAPI strctures for specification- data:

*

  • additional information for function modules: addinf

  • return table (errors): bapiret2

  • specification header: bapi1077rh

  • identifier header: bapi1077ri

  • identifier Longtexts: bapi1077il

  • sublist assignments: bapi1077rl

  • property header: bapi1077vh

  • property usage: bapi1077du

  • property values: bapi1077va

  • property assessments: bapi1077dr

  • property components: bapi1077vp

  • property data: bapi1077pr

  • property freetexts: bapi1077df

  • property longtexts: bapi1077fl

  • property source: bapi1077ds

*

*&----


*

*

  • Used BAPI- Functions (examples):

  • All the tables for the data to set have to be prepared like

  • in the used methods.

*

*

  • Create new specification:

*

  • CALL FUNCTION 'BAPI_BUS1077_CREATE'

  • EXPORTING

  • key_date = addinf-valdat

  • change_number = addinf-aennr

  • flg_header = 'X'

  • flg_ident = 'X'

  • flg_ident_longtext = 'X'

  • flg_ident_sublist = 'X'

  • flg_prop_usage = 'X'

  • flg_prop_header = 'X' " These Flags specify the data to be edited

  • flg_prop = 'X'

  • flg_prop_rel = 'X'

  • flg_prop_comp = 'X'

  • flg_prop_data = 'X'

  • flg_prop_ftext = 'X'

  • flg_prop_ftext_longtext = 'X'

  • TABLES

  • return = l_return_tab " This table contains possible errors to occure

  • sub_header = l_sub_header_tab

  • ident_header = l_ident_header_tab

  • ident_longtext = l_ident_longtext_tab

  • ident_sublist = l_ident_sublist_tab

  • prop_usage = l_prop_usage_tab

  • prop_header = l_prop_header_tab " These tables contain the data to set

  • prop_val = l_prop_val_tab

  • prop_reliability = l_prop_assess_tab

  • prop_component = l_prop_component_tab

  • prop_data = l_prop_data_tab

  • prop_ftext = l_prop_ftext_tab

  • prop_ftext_longtext = l_prop_ftext_longtext_tab.

*

*

  • The following function works the same way:

  • BAPI_BUS1077_DELETE (delete specification or single data from specification)

*

*

  • Change specification data:

*

  • CALL FUNCTION 'BAPI_BUS1077_CHANGE'

  • EXPORTING

  • flg_ident_usage = 'X' " data to be changed

  • TABLES

  • return = l_return_tab

  • sub_header = l_sub_header_tab

  • ident_header = l_ident_header_tab

  • prop_usage = l_prop_usage_tab " table with changed data

  • prop_usagex = l_prop_usagex_tab. " table to specifiy wich fields are changed

*

*

*

  • After all these functions, the follwing two functions have

  • to be executed to commit the work and write the data from

  • the buffer to the dictionary (for details have a look at the used methods below):

*

  • BAPI_TRANSACTION_COMMIT(always set the wait-flag!)

  • BAPI_BUS1077_SAVEFROMBUFFER

*

*

  • Exceptions are the following functions to read data from specifications

  • and check if a specification exists.

  • These functions usually stand alone without "commit" and "save":

*

*

  • Get specification details:

*

  • CALL FUNCTION 'BAPI_BUS1077_GETDETAIL'

  • EXPORTING

  • key_date = addinf-valdat

  • change_number = addinf-aennr

  • flg_header = 'X'

  • flg_ident = 'X'

  • flg_ident_usage = 'X'

  • scenario = '1' "specifies the way, the data are read (F1-help for details)

  • TABLES

  • return = l_return_tab

  • sub_header = l_sub_header_tab

  • ident_header = l_ident_header_tab

  • prop_usage = l_prop_usage_tab.

*

*

  • Check if a specification exists:

*

  • CALL FUNCTION 'BAPI_BUS1077_EXISTENCECHECK'

  • EXPORTING

  • substanceid = l_spec_key "The spec-Key, that is searched for

  • key_date = addinf-valdat

  • TABLES

  • return = l_return_tab.

*

*&----


*

*

  • Helpful methods:

*

  • set_dis_tab: Fills the error-table to display for each test-method

  • get_random_matnr: Selects a random material-id from the dictionary, to work with

  • get_random_source: Selects a random source-id.

  • get_random_phrase: Selects a random phrase from given selection-set

*

*&----


*

report rc1_1077_bapi_example_change.

include cbui09.

type-pools: espap.

*&----


*

*& Include L1077P01

*&----


*

*&----


*

*& Include LC1F2P03

*&----


*

*&----


*

*& EHS ABAP UNIT TEMPLATE BACKUP

*&----


*

*&----


*

  • The methods with be called in this order:

  • class_setup

  • test1

  • test2

  • class_teardown

*

*&----


*

*&----


*

*& Class (Definition) lcl_aunit_template

*&----


*

  • Template for ABAP Unit

*----


*

class lcl_bus1077_change_test definition.

type-pools: espph.

public section.

class-methods:

  • creates the two test-specifications with properties

class_setup,

  • deletes the two specifications

class_teardown,

*----


*

test_change_comp,

  • This test changes the first component in the property

  • "Exact composition based on compound"

  • Prerequisites: Created specification which

  • has this property set. The test fails if the component's data

  • was not changed properly.

  • List of properties that are changed:

*

  • COMPCAT = 'EMULSIFIER'.

  • OPLOWLIMIT = '>'.

  • LOW_LIMIT = '0.15'.

  • OPUPPLIMIT = '<='.

  • UPP_LIMIT = '0.88'.

  • AVG_VAL = '0.88'.

  • EXPONENT = 'PPM'.

*----


*

*----


*

test_change_ident,

  • This test changes the first identifier of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the identifier

  • was not changed properly.

  • List of properties that are changed:

*

  • ID_TYPE = 'FRM'.

  • ID_CATEGRY = 'RAT'.

  • LANGU = 'E'.

  • IDENTIFIER = 'H2SO4'.

*----


*

*----


*

test_change_ident_longtext,

  • This test changes the identifier longtext of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the identifier longtext

  • was not changed properly.

  • List of properties that are changed:

*

  • Four lines of the identifier longtext are changed:

*

  • TEXT_LINE = 'Changed long text for ABAP Unit (LINE 1).'.

  • TEXT_LINE = 'Changed long text for ABAP Unit (LINE 2).'.

  • TEXT_LINE = 'Changed long text for ABAP Unit (LINE 3).'.

  • TEXT_LINE = 'Changed long text for ABAP Unit (LINE 4).'.

*

*----


*

*----


*

test_change_ident_usage,

  • This test changes the identifier usage of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the identifier usage

  • was not changed properly.

  • List of properties that are changed:

*

  • RATING = 'PUBLIC'.

  • VAL_AREA = 'REG_WORLD'.

  • EXCL_IND = FALSE.

  • ACT_IND = TRUE.

*----


*

*----


*

test_change_prop_usage,

  • This test changes the first property usage of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the property usage

  • was not changed properly.

  • List of properties that are changed:

*

  • RATING = 'PUBLIC'.

  • VAL_AREA = 'REG_WORLD'.

  • EXCL_IND = FALSE.

  • ACT_IND = TRUE.

*----


*

*----


*

test_change_subheader,

  • This test changes the sub header of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the sub header

  • was not changed properly.

  • List of properties that are changed:

  • SUBAUTHGRP = 'ALL'.

  • NOTE = 'Changed note!'.

  • SUBCHARACT = 'SUB_NOPOLY'.

*----


*

*----


*

test_ref_subs,

  • This test's purpose is to assure that specification references

  • can be created successfully.

  • Scenario:

  • 1. Create 2 specifications(one with property values set, the other without)

  • 2. Create a reference from the second spec to the first

  • 3. Verify that the specifications have at least one property which

  • is the same - this will assure that the reference has been

  • created successfully

*

  • result: l_dis_tab_9

*----


*

*----


*

test_change_prop_ftext,

  • This test changes the property ftext & longtext of a specification

  • Prerequisites: Created specification which

  • has these properties set. The test fails if the UD longtext

  • was not changed properly.

  • List of properties that are changed:

*

  • User defined text:

*

  • USRDFNDTXT = 'Changed user-defined text for ABAP Unit (LINE 1).'.

  • FORMAT_FLAG = TRUE.

  • UD_TXTTYPE = 'RM'. " Remark

  • LANGU = 'EN'.

  • LONG_TEXT = TRUE.

*

  • Four lines of the UD longtext are changed:

*

  • TEXT_LINE = 'Changed user-defined long text for ABAP Unit (LINE 1).'.

  • TEXT_LINE = 'Changed user-defined long text for ABAP Unit (LINE 2).'.

  • TEXT_LINE = 'Changed user-defined long text for ABAP Unit (LINE 3).'.

  • TEXT_LINE = 'Changed user-defined long text for ABAP Unit (LINE 4).'.

*----


*

*----


*

test_change_assessment,

  • This test changes the assessment of a value assignment

  • Prerequisites: Created specification which:

  • - Has the predefined dafault property set. The test fails if the property assessment

  • don't change properly.

  • - List of properties that are changed:

  • ASSESSMENT = '2'.

*----


*

*----


*

test_change_prop_data,

  • This test changes the property data of a value assignment

  • Prerequisites: Created specification which:

  • - Has the predefined dafault property set. The test fails if the

  • property data doesn't change properly.

  • - Changed data:

  • CHAR_VALUE = <random phrase>.

*----


*

*----


*

test_read_usage_filter,

  • This test assures that the usage filter is working properly

  • Prerequisites: Created specification which:

  • - Has property usage set to PUBLIC/EU or PUBLIC/REG_WORLD.

*

  • This test has two scenarios:

  • 1-st:

  • Read the value assignments with filter which should not find

  • any value assignments matching the criteria.

  • Criteria: INTERNAL/REG_WORLD

*

  • 2-nd:

  • Read the value assignments with filter which should find

  • one value assignment matching the criteria.

  • Criteria: PUBLIC/ES

*----


*

*----


*

test_del_ref,

  • This test deletes all references of a specification

*

*----


*

  • methods to edit the displayed table from l_return_tab

set_dis_tab

importing

i_table type bapiret2_t

i_wa type bapiret2

i_meth type c

i_tab_flg type c

i_func type c

i_func_desc type c

i_spec_key type c,

get_dis_tab

exporting

e_dis_tab type standard table,

set_dis_wa

importing

i_meth_wa type c

i_func_wa type c

i_func_desc_wa type c

i_error_desc_wa type c

i_spec_key_wa type c,

get_dis_wa

exporting

e_meth_wa type c

e_func_wa type c

e_func_desc_wa type c

e_error_desc_wa type c

e_spec_key_wa type c,

  • Gets matnumber of a random Matrial in DIC-Table "MAKT"

get_random_matnr

exporting

e_mat_nr type c,

  • Text of random source

get_random_source

exporting

e_source type c,

  • Random Phrase-text for given phrase selection set

get_random_phrase

importing

i_phrase_sel_set type c

exporting

e_phrase_id type c,

write_table_to_list

importing

i_method type c

i_dis_tab type standard table.

private section.

  • Class DATA:

class-data: sub_header_tab type standard table of bapi1077rh,

sub_header_wa like line of sub_header_tab.

class-data: spec_key like sub_header_wa-substance,

spec_key_pre like sub_header_wa-substance.

class-data va_recn type eserecn.

class-data: addinf type rcgaddinf.

class-data: scenario type bapistdtyp-scenario.

class-data: error_occured type i.

class-data: int_error_occured type i.

class-data: error_message2 type bapi_msg.

class-data: error_type type bapi_mtype.

class-data: error_section(100) type c.

  • Internal table, for displayed information

types:

begin of l_dis_rec,

meth(32) type c,

func(32) type c,

func_desc(64) type c,

error_desc(64) type c,

spec_key(12) type c,

end of l_dis_rec,

l_dis_type type l_dis_rec.

class-data:

l_dis_tab type table of l_dis_type,

l_dis_wa like line of l_dis_tab.

endclass. "lcl_BUS1077_change_test DEFINITIO

*&----


*

*& Global Data

*&----


*

types:

begin of lg_dis_rec,

meth(32) type c,

func(32) type c,

func_desc(64) type c,

error_desc(64) type c,

spec_key(12) type c,

end of lg_dis_rec,

lg_dis_type type lg_dis_rec.

data:

lg_dis_tab type table of lg_dis_type,

lg_dis_wa like line of lg_dis_tab.

  • Data for Dynpro

data:

ok_code like sy-ucomm,

  • ALV-Grid for method test_cr_all_spec_dtls_bylrs

g_container_1 type scrfname value 'BCALV_GRID_BAPI_EXPL',

grid1 type ref to cl_gui_alv_grid,

g_custom_container type ref to cl_gui_custom_container,

lg_fcat_tab type lvc_t_fcat,

lg_fcat_wa like line of lg_fcat_tab.

*&----


*

*& Prepare field catalogue for ALV-grids

*&----


*

lg_fcat_wa-fieldname = 'METH'.

lg_fcat_wa-inttype = 'C'.

lg_fcat_wa-outputlen = '32'.

lg_fcat_wa-coltext = text-007.

lg_fcat_wa-seltext = text-007.

append lg_fcat_wa to lg_fcat_tab.

lg_fcat_wa-fieldname = 'FUNC'.

lg_fcat_wa-inttype = 'C'.

lg_fcat_wa-outputlen = '32'.

lg_fcat_wa-coltext = text-008.

lg_fcat_wa-seltext = text-008.

append lg_fcat_wa to lg_fcat_tab.

lg_fcat_wa-fieldname = 'FUNC_DESC'.

lg_fcat_wa-inttype = 'C'.

lg_fcat_wa-outputlen = '64'.

lg_fcat_wa-coltext = text-009.

lg_fcat_wa-seltext = text-009.

append lg_fcat_wa to lg_fcat_tab.

lg_fcat_wa-fieldname = 'ERROR_DESC'.

lg_fcat_wa-inttype = 'C'.

lg_fcat_wa-outputlen = '64'.

lg_fcat_wa-coltext = text-010.

lg_fcat_wa-seltext = text-010.

append lg_fcat_wa to lg_fcat_tab.

lg_fcat_wa-fieldname = 'SPEC_KEY'.

lg_fcat_wa-inttype = 'C'.

lg_fcat_wa-outputlen = '12'.

lg_fcat_wa-coltext = text-011.

lg_fcat_wa-seltext = text-011.

append lg_fcat_wa to lg_fcat_tab.

*&----


*

*& Execute methods and write result to list

*&----


*

  • Execute methods...

lcl_bus1077_change_test=>class_setup( ).

lcl_bus1077_change_test=>test_change_subheader( ).

lcl_bus1077_change_test=>test_change_ident( ).

lcl_bus1077_change_test=>test_change_ident_usage( ).

lcl_bus1077_change_test=>test_change_prop_ftext( ).

lcl_bus1077_change_test=>test_change_prop_usage( ).

lcl_bus1077_change_test=>test_change_ident_longtext( ).

lcl_bus1077_change_test=>test_read_usage_filter( ).

lcl_bus1077_change_test=>test_ref_subs( ).

lcl_bus1077_change_test=>test_change_comp( ).

lcl_bus1077_change_test=>test_change_assessment( ).

lcl_bus1077_change_test=>test_change_prop_data( ).

lcl_bus1077_change_test=>test_del_ref( ).

lcl_bus1077_change_test=>class_teardown( ).

  • ...get tables to display...

lcl_bus1077_change_test=>get_dis_tab( importing e_dis_tab = lg_dis_tab ).

*...and call Dynpro

call screen 100.

*&----


*

*& Class (Definition) aunit_template

*&----


*

class lcl_bus1077_change_test implementation.

*----


*

method class_setup.

  • this method is called only once before all test methods

*----


*

  • Local DATA:

data: addinf type rcgaddinf.

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab,

l_sub_header_pre_wa like line of l_sub_header_tab.

data: l_spec_key like l_sub_header_wa-substance,

l_spec_key_pre like l_sub_header_wa-substance,

l_spec_recn like l_sub_header_wa-record_no.

data: l_ident_header_tab type standard table of bapi1077ri,

l_ident_header_wa like line of l_ident_header_tab.

data: l_ident_recn like l_ident_header_wa-record_no.

data: l_ident_longtext_tab type standard table of bapi1077il,

l_ident_longtext_wa like line of l_ident_longtext_tab.

data: l_ident_sublist_tab type standard table of bapi1077rl,

l_ident_sublist_wa like line of l_ident_sublist_tab.

data: l_prop_usage_tab type standard table of bapi1077du,

l_prop_usage_wa like line of l_prop_usage_tab.

data: l_prop_usage_buf1 like l_prop_usage_wa,

l_prop_usage_buf2 like l_prop_usage_wa.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_subchacat like l_prop_header_wa-subchacat.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data l_prop_val_recn like l_prop_val_wa-record_no.

data: l_prop_assess_tab type standard table of bapi1077dr,

l_prop_assess_wa like line of l_prop_assess_tab.

data: l_prop_component_tab type standard table of bapi1077vp,

l_prop_component_wa like line of l_prop_component_tab.

data: l_prop_data_tab type standard table of bapi1077pr,

l_prop_data_wa like line of l_prop_data_tab.

data: l_prop_ftext_tab type standard table of bapi1077df,

l_prop_ftext_wa like line of l_prop_ftext_tab.

data l_prop_ftext_recn like l_prop_ftext_wa-record_no.

data: l_prop_ftext_longtext_tab type standard table of bapi1077fl,

l_prop_ftext_longtext_wa like line of l_prop_ftext_longtext_tab.

data: l_prop_source_tab type standard table of bapi1077ds,

l_prop_source_wa like line of l_prop_source_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

data: l_scenario type bapistdtyp-scenario.

data: l_phrase_id(30) type c,

l_source_id(10) type c.

  • ----------------------------

  • 1.1. create a new SPECIFICATION HEADER (pre) & verify the creation

  • ----------------------------

  • prepare the a SPECIFICATION HEAD

refresh l_sub_header_tab.

clear l_sub_header_wa.

addinf-valdat = '20070125'. "key date 01/25/2007

clear addinf-aennr. "change number

l_sub_header_wa-primarykey = 1. "int. key

l_sub_header_wa-flgprimkey = true.

l_sub_header_wa-subcategry = 'REAL_SUB'. "spec. category

l_sub_header_wa-subauthgrp = 'ALL'. "spec. auth. group

append l_sub_header_wa to l_sub_header_tab.

  • call the BAPI function module to create specification

call function 'BAPI_BUS1077_CREATE'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

tables

return = l_return_tab

sub_header = l_sub_header_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'class_setup'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CREATE'

i_func_desc = text-000

i_spec_key = l_sub_header_wa-substance.

  • commit work

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'class_setup'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'class_setup'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

  • prepare L_SUB_HEADER_TAB for BAPI_BUS1077_GETDETAIL

read table l_sub_header_tab

into l_sub_header_wa

index 1

transporting substance.

l_spec_key_pre = l_sub_header_wa-substance.

refresh l_sub_header_tab.

clear l_sub_header_wa.

l_sub_header_wa-substance = l_spec_key_pre.

append l_sub_header_wa to l_sub_header_tab.

  • set scenario

add espap_scenario-header_disp to l_scenario.

  • call the BAPI function module

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

scenario = l_scenario

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

tables

return = l_return_tab

sub_header = l_sub_header_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'class_setup'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • read the newly cretated SUB. RECORD NUMBER

read table l_sub_header_tab

into l_sub_header_wa

index 1

transporting record_no

substance.

l_spec_recn = l_sub_header_wa-record_no.

spec_key_pre = l_sub_header_wa-substance.

  • ------------------------------------------------------------*

  • 2.1. Prepare all specification detail data for new creation

  • ------------------------------------------------------------*

  • prepare the new SPECIFICATION HEADER

refresh: l_sub_header_tab.

clear l_sub_header_wa.

addinf-valdat = '20070125'. "key date 01/25/2007

clear addinf-aennr. "change number

l_sub_header_wa-primarykey = 2. "int. key

l_sub_header_wa-flgprimkey = true.

l_sub_header_wa-subcategry = 'LIST_SUB'. "spec. category

l_sub_header_wa-subauthgrp = 'ALL'. "spec. auth. group

append l_sub_header_wa to l_sub_header_tab.

  • prepare the new IDENTIFIER HEADER

refresh: l_ident_header_tab.

clear l_ident_header_wa.

l_ident_header_wa-primarykey = 21. "int. key

l_ident_header_wa-flgprimkey = true.

l_ident_header_wa-foreignkey = l_sub_header_wa-primarykey.

l_ident_header_wa-flgfrgnkey = l_sub_header_wa-flgprimkey.

l_ident_header_wa-id_type = 'NAM'. "ident.'s type

l_ident_header_wa-id_categry = 'PROD'. "ident.'s category

l_ident_header_wa-langu = 'E'. "ident.'s language

l_ident_header_wa-identifier = 'Test for ABAP Unit'. "#EC *

append l_ident_header_wa to l_ident_header_tab.

l_ident_header_wa-long_text = true.

  • prepare the IDENTIFIER LONGTEXT

refresh: l_ident_longtext_tab.

clear l_ident_longtext_wa.

l_ident_longtext_wa-primarykey = 211. "int. key

l_ident_longtext_wa-flgprimkey = true.

l_ident_longtext_wa-foreignkey = l_ident_header_wa-primarykey.

l_ident_longtext_wa-flgfrgnkey = l_ident_header_wa-flgprimkey.

l_ident_longtext_wa-text_line = 'Test long text for ABAP Unit (LINE 1).'. "#EC NOTEXT

l_ident_longtext_wa-format_col = '*'.

l_ident_longtext_wa-loglockmod = true.

append l_ident_longtext_wa to l_ident_longtext_tab.

l_ident_longtext_wa-primarykey = 212. "int. key

l_ident_longtext_wa-text_line = 'Test long text for ABAP Unit (LINE 2).'. "#EC NOTEXT

append l_ident_longtext_wa to l_ident_longtext_tab.

l_ident_longtext_wa-primarykey = 213. "int. key

l_ident_longtext_wa-text_line = 'Test long text for ABAP Unit (LINE 3).'. "#EC NOTEXT

append l_ident_longtext_wa to l_ident_longtext_tab.

l_ident_longtext_wa-primarykey = 214. "int. key

l_ident_longtext_wa-text_line = 'Test long text for ABAP Unit (LINE 4).'. "#EC NOTEXT

append l_ident_longtext_wa to l_ident_longtext_tab.

  • prepare the IDENTIFIER SUBLIST

refresh: l_ident_sublist_tab.

clear l_ident_sublist_wa.

l_ident_sublist_wa-primarykey = 215. "int. key

l_ident_sublist_wa-flgprimkey = true.

l_ident_sublist_wa-foreignkey = l_ident_header_wa-primarykey.

l_ident_sublist_wa-flgfrgnkey = l_ident_header_wa-flgprimkey.

l_ident_sublist_wa-valid_from = '20070125'. "date 01/25/2007

l_ident_sublist_wa-valid_to = '20080125'. "date 01/25/2008

l_ident_sublist_wa-sublist = 'EINECS'.

append l_ident_sublist_wa to l_ident_sublist_tab.

  • prepare the IDENTIFIER USAGE

refresh: l_prop_usage_tab.

clear l_prop_usage_wa.

l_prop_usage_wa-primarykey = 216. "int. key

l_prop_usage_wa-flgprimkey = true.

l_prop_usage_wa-foreignkey = l_ident_header_wa-primarykey.

l_prop_usage_wa-flgfrgnkey = l_ident_header_wa-flgprimkey.

l_prop_usage_wa-mastertabl = 'ESTRI'.

l_prop_usage_wa-rating = 'PUBLIC'.

l_prop_usage_wa-val_area = 'REG_EU'.

l_prop_usage_wa-excl_ind = false.

l_prop_usage_wa-act_ind = true.

append l_prop_usage_wa to l_prop_usage_tab.

  • prepare the PROPERTY HEADER

refresh: l_prop_header_tab.

clear l_prop_header_wa.

l_prop_header_wa-primarykey = 22. "int. key

l_prop_header_wa-flgprimkey = true.

l_prop_header_wa-foreignkey = l_sub_header_wa-primarykey.

l_prop_header_wa-flgfrgnkey = l_sub_header_wa-flgprimkey.

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. "Chemical Characterization

append l_prop_header_wa to l_prop_header_tab.

  • prepare the VALUE tab

refresh: l_prop_val_tab.

clear l_prop_val_wa.

l_prop_val_wa-primarykey = 221.

l_prop_val_wa-flgprimkey = true.

l_prop_val_wa-foreignkey = l_prop_header_wa-primarykey.

l_prop_val_wa-flgfrgnkey = l_prop_header_wa-flgprimkey.

l_prop_val_wa-sequence = 1.

append l_prop_val_wa to l_prop_val_tab.

  • prepare the VALUE ASSIGNMENT ASSESSMENT tab

refresh: l_prop_assess_tab.

clear l_prop_assess_wa.

l_prop_assess_wa-primarykey = 2211.

l_prop_assess_wa-flgprimkey = true.

l_prop_assess_wa-foreignkey = l_prop_val_wa-primarykey.

l_prop_assess_wa-flgfrgnkey = l_prop_val_wa-flgprimkey.

l_prop_assess_wa-assessment = '1'.

append l_prop_assess_wa to l_prop_assess_tab.

  • Get random phrase-text

call method get_random_phrase

exporting

i_phrase_sel_set = 'SAP_EHS_1012_015_REMARK'

importing

e_phrase_id = l_phrase_id.

  • prepare the VALUE ASSIGNMENT DATA tab

refresh: l_prop_data_tab.

clear l_prop_data_wa.

l_prop_data_wa-primarykey = 2212.

l_prop_data_wa-flgprimkey = true.

l_prop_data_wa-foreignkey = l_prop_val_wa-primarykey.

l_prop_data_wa-flgfrgnkey = l_prop_val_wa-flgprimkey.

l_prop_data_wa-char_value = l_phrase_id.

l_prop_data_wa-name_char = 'SAP_EHS_1012_015_REMARK'. "Chemical Characterization

l_prop_data_wa-oper_inc = 0.

append l_prop_data_wa to l_prop_data_tab.

  • prepare the VALUE ASSIGNMENT COMPONENT tab

refresh: l_prop_component_tab.

clear l_prop_component_wa.

l_prop_component_wa-primarykey = 2213.

l_prop_component_wa-flgprimkey = true.

l_prop_component_wa-foreignkey = l_prop_val_wa-primarykey.

l_prop_component_wa-flgfrgnkey = l_prop_val_wa-flgprimkey.

l_prop_component_wa-comproot = l_spec_recn.

l_prop_component_wa-compcat = 'ACT_AGENT'.

l_prop_component_wa-sequence = 1.

l_prop_component_wa-oplowlimit = '>'.

l_prop_component_wa-low_limit = '0.55'.

l_prop_component_wa-opupplimit = '<='.

l_prop_component_wa-upp_limit = '0.88'.

l_prop_component_wa-avg_val = '0.88'.

l_prop_component_wa-exponent = 'PPT'.

append l_prop_component_wa to l_prop_component_tab.

  • prepare the USER-DEFINED TEXTS tab

refresh: l_prop_ftext_tab.

clear l_prop_ftext_wa.

l_prop_ftext_wa-primarykey = 2214.

l_prop_ftext_wa-flgprimkey = true.

l_prop_ftext_wa-foreignkey = l_prop_val_wa-primarykey.

l_prop_ftext_wa-flgfrgnkey = l_prop_val_wa-flgprimkey.

l_prop_ftext_wa-usrdfndtxt = 'Test user-defined text for ABAP Unit (LINE 1).'. "#EC NOTEXT

l_prop_ftext_wa-format_flag = true.

l_prop_ftext_wa-loglockmod = true.

l_prop_ftext_wa-ud_txttype = 'RM'. " Remark "CT

l_prop_ftext_wa-sequence = 4.

l_prop_ftext_wa-langu = 'E'.

l_prop_ftext_wa-long_text = true.

append l_prop_ftext_wa to l_prop_ftext_tab.

  • prepare the VAL. ASSMT UD TEXTS

refresh: l_prop_ftext_longtext_tab.

clear l_prop_ftext_longtext_wa.

l_prop_ftext_longtext_wa-primarykey = 22141. "int. key

l_prop_ftext_longtext_wa-flgprimkey = true.

l_prop_ftext_longtext_wa-foreignkey = l_prop_ftext_wa-primarykey.

l_prop_ftext_longtext_wa-flgfrgnkey = l_prop_ftext_wa-flgprimkey.

l_prop_ftext_longtext_wa-text_line = 'Test user-defined long text for ABAP Unit (LINE 1).'. "#EC NOTEXT

l_prop_ftext_longtext_wa-format_col = '*'.

l_prop_ftext_longtext_wa-loglockmod = true.

append l_prop_ftext_longtext_wa to l_prop_ftext_longtext_tab.

l_prop_ftext_longtext_wa-primarykey = 22142. "int. key

l_prop_ftext_longtext_wa-text_line = 'Test user-defined long text for ABAP Unit (LINE 2).'. "#EC NOTEXT

append l_prop_ftext_longtext_wa to l_prop_ftext_longtext_tab.

l_prop_ftext_longtext_wa-primarykey = 22143. "int. key

l_prop_ftext_longtext_wa-text_line = 'Test user-defined long text for ABAP Unit (LINE 3).'. "#EC NOTEXT

append l_prop_ftext_longtext_wa to l_prop_ftext_longtext_tab.

  • Get random source

call method get_random_source

importing

e_source = l_source_id.

  • prepare the USER-DEFINED TEXTS tab

refresh: l_prop_source_tab.

clear l_prop_source_wa.

l_prop_source_wa-primarykey = 2215.

l_prop_source_wa-flgprimkey = true.

l_prop_source_wa-foreignkey = l_prop_val_wa-primarykey.

l_prop_source_wa-flgfrgnkey = l_prop_val_wa-flgprimkey.

l_prop_source_wa-source = l_source_id.

l_prop_source_wa-srce_note = 'Test source note text for ABAP Unit.'. "#EC NOTEXT

append l_prop_source_wa to l_prop_source_tab.

  • ----------------------------

  • 2.2. Create - BAPI function call for specification details data

  • ----------------------------

  • call the BAPI function module

refresh l_return_tab.

call function 'BAPI_BUS1077_CREATE'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_ident = true

flg_ident_longtext = true

flg_ident_sublist = true

flg_prop_usage = true

flg_prop_header = true

flg_prop = true

flg_prop_rel = true

flg_prop_comp = true

flg_prop_data = true

flg_prop_ftext = true

flg_prop_ftext_longtext = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab

ident_longtext = l_ident_longtext_tab

ident_sublist = l_ident_sublist_tab

prop_usage = l_prop_usage_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_reliability = l_prop_assess_tab

prop_component = l_prop_component_tab

prop_data = l_prop_data_tab

prop_ftext = l_prop_ftext_tab

prop_ftext_longtext = l_prop_ftext_longtext_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'class_setup'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CREATE'

i_func_desc = text-000

i_spec_key = l_sub_header_wa-substance.

  • commit work

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'class_setup'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'class_setup'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

  • Save the Value assignment RECORD_NO for later use

read table l_prop_val_tab

into l_prop_val_wa

index 1

transporting record_no.

va_recn = l_prop_val_wa-record_no.

  • Save the spec key for later use

read table l_sub_header_tab

into l_sub_header_wa

index 1

transporting substance.

spec_key = l_sub_header_wa-substance.

  • ----------------------------

  • 2.4. Prepare tables for get details call

  • ----------------------------

  • prepare L_SUB_HEADER_TAB for BAPI_BUS1077_GETDETAIL

read table l_sub_header_tab

into l_sub_header_wa

index 1

transporting substance.

l_spec_key = l_sub_header_wa-substance.

refresh l_sub_header_tab.

clear l_sub_header_wa.

l_sub_header_wa-substance = l_spec_key.

append l_sub_header_wa to l_sub_header_tab.

  • prepare L_IDENT_HEADER_TAB for BAPI_BUS1077_GETDETAIL

read table l_ident_header_tab

into l_ident_header_wa

index 1

transporting record_no.

l_ident_recn = l_ident_header_wa-record_no.

refresh l_ident_header_tab.

clear l_ident_header_wa.

l_ident_header_wa-record_no = l_ident_recn.

append l_ident_header_wa to l_ident_header_tab.

  • prepare L_PROP_HEADER_TAB for BAPI_BUS1077_GETDETAIL

read table l_prop_header_tab

into l_prop_header_wa

index 1

transporting subchacat.

l_prop_subchacat = l_prop_header_wa-subchacat.

refresh l_prop_header_tab.

clear l_prop_header_wa.

l_prop_header_wa-subchacat = l_prop_subchacat.

append l_prop_header_wa to l_prop_header_tab.

  • prepare L_PROP_VAL_TAB for BAPI_BUS1077_GETDETAIL

read table l_prop_val_tab

into l_prop_val_wa

index 1

transporting record_no.

l_prop_val_recn = l_prop_val_wa-record_no.

refresh l_prop_val_tab.

clear l_prop_val_wa.

l_prop_val_wa-record_no = l_prop_val_recn.

append l_prop_val_wa to l_prop_val_tab.

  • prepare L_PROP_USAGE_TAB for BAPI_BUS1077_GETDETAIL

clear: l_prop_usage_wa, l_prop_usage_buf1, l_prop_usage_buf2.

read table l_prop_usage_tab

into l_prop_usage_wa

index 1

transporting all fields.

l_prop_usage_buf1-rating = l_prop_usage_wa-rating.

l_prop_usage_buf1-val_area = l_prop_usage_wa-val_area.

l_prop_usage_buf1-excl_ind = l_prop_usage_wa-excl_ind.

clear l_prop_usage_wa.

read table l_prop_usage_tab

into l_prop_usage_wa

index 2

transporting all fields.

l_prop_usage_buf2-rating = l_prop_usage_wa-rating.

l_prop_usage_buf2-val_area = l_prop_usage_wa-val_area.

l_prop_usage_buf2-excl_ind = l_prop_usage_wa-excl_ind.

clear l_prop_usage_wa.

refresh l_prop_usage_tab.

append l_prop_usage_buf1 to l_prop_usage_tab.

append l_prop_usage_buf2 to l_prop_usage_tab.

  • prepare L_IDENT_LONGTEXT_TAB for BAPI_BUS1077_GETDETAIL

refresh l_ident_longtext_tab.

  • prepare L_IDENT_SUBLIST_TAB for BAPI_BUS1077_GETDETAIL

refresh l_ident_sublist_tab.

  • prepare L_PROP_ASSESS_TAB for BAPI_BUS1077_GETDETAIL

refresh l_prop_assess_tab.

  • prepare L_PROP_COMPONENT_TAB for BAPI_BUS1077_GETDETAIL

refresh l_prop_component_tab.

  • prepare L_PROP_FTEXT_TAB for BAPI_BUS1077_GETDETAIL

read table l_prop_ftext_tab

into l_prop_ftext_wa

index 1

transporting record_no.

l_prop_ftext_recn = l_prop_ftext_wa-record_no.

refresh l_prop_ftext_tab.

clear l_prop_ftext_wa.

l_prop_ftext_wa-record_no = l_prop_ftext_recn.

append l_prop_ftext_wa to l_prop_ftext_tab.

  • prepare L_PROP_FTEXT_LONGTEXT_TAB for BAPI_BUS1077_GETDETAIL

refresh l_prop_ftext_longtext_tab.

  • prepare L_PROP_SOURCE_TAB for BAPI_BUS1077_GETDETAIL

refresh l_prop_source_tab.

  • prepare L_PROP_DATA_TAB for BAPI_BUS1077_GETDETAIL

refresh l_prop_data_tab.

  • ----------------------------

  • 2.5. Get details - BAPI function call for specification details data

  • ----------------------------

  • set the scenario

add espap_scenario-header_disp to l_scenario.

add espap_scenario-level2_disp to l_scenario.

add espap_scenario-level3_disp to l_scenario.

add espap_scenario-level4_disp to l_scenario.

  • call the BAPI function module

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

scenario = l_scenario

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_ident = true

flg_ident_longtext = true

flg_ident_usage = true

flg_properties = true

flg_prop_details = true

flg_prop_data = true

flg_prop_ftext_longtext = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab

ident_longtext = l_ident_longtext_tab

ident_sublist = l_ident_sublist_tab

prop_usage = l_prop_usage_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_reliability = l_prop_assess_tab

prop_data = l_prop_data_tab

prop_component = l_prop_component_tab

prop_ftext = l_prop_ftext_tab

prop_ftext_longtext = l_prop_ftext_longtext_tab

prop_source = l_prop_source_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'class_setup'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. "class_setup

*----


*

method class_teardown.

  • this method is called once after the execution of all test methods

*----


*

*----


*

  • Deletion of first specification *

*----


*

data: return_tab type standard table of bapiret2,

return_wa like line of return_tab.

clear sub_header_wa.

refresh sub_header_tab.

*Prepare the sub-header table for the deletion of the test specification

sub_header_wa-substance = spec_key.

append sub_header_wa to sub_header_tab.

  • Delete the substance

refresh return_tab.

call function 'BAPI_BUS1077_DELETE'

exporting

flg_header = true

tables

return = return_tab

sub_header = sub_header_tab.

  • commit work

clear return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = return_wa.

  • remove locks (according to note 732628)

refresh return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = return_tab.

*----


*

  • Deletion of second specification *

*----


*

clear sub_header_wa.

refresh sub_header_tab.

  • Prepare the sub-header table for the deletion of the test specification pre.

sub_header_wa-substance = spec_key_pre.

append sub_header_wa to sub_header_tab.

  • Delete the substance

refresh return_tab.

call function 'BAPI_BUS1077_DELETE'

exporting

flg_header = true

tables

return = return_tab

sub_header = sub_header_tab.

  • commit work

clear return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = return_wa.

  • remove locks (according to note 732628)

refresh return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = return_tab.

endmethod. "class_teardown

*----


*

method test_change_subheader.

  • This test changes the sub header of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the sub header

  • was not changed properly.

  • List of properties that are changed:

  • SUBAUTHGRP = 'ALL'.

  • NOTE = 'Changed note!'.

  • SUBCHARACT = 'SUB_NOPOLY'.

*----


*

  • Local DATA:

data: addinf type rcgaddinf.

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab,

l_sub_headerx_tab type standard table of bapisubrhx,

l_sub_headerx_wa like line of l_sub_headerx_tab.

data: l_spec_key like l_sub_header_wa-substance,

l_spec_key_pre like l_sub_header_wa-substance,

l_spec_recn like l_sub_header_wa-record_no.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data: l_prop_data_tab type standard table of bapi1077pr,

l_prop_data_wa like line of l_prop_data_tab.

data: l_prop_component_tab type standard table of bapi1077vp,

l_prop_component_wa like line of l_prop_component_tab.

data: l_prop_componentx_tab type standard table of bapisubvpx,

l_prop_componentx_wa like line of l_prop_componentx_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

  • Prepare the L_SUB_HEADER_TAB

refresh: l_sub_header_tab.

clear l_sub_header_wa.

addinf-valdat = '20070125'. "key date 01/25/2007

clear addinf-aennr. "change number

l_sub_header_wa-primarykey = 1. "int. key

l_sub_header_wa-flgprimkey = true.

l_sub_header_wa-substance = spec_key.

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_subheader'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • Clear the sub_header WA

clear l_sub_header_wa.

l_sub_header_wa-subcategry = 'LIST_SUB'. "spec. category

l_sub_header_wa-subauthgrp = 'ALL'. "spec. auth. group

l_sub_header_wa-note = 'Changed note!'. "#EC NOTEXT

l_sub_header_wa-subcharact = 'SUB_NOPOLY'.

modify l_sub_header_tab from l_sub_header_wa index 1

transporting note

subcharact

subauthgrp.

  • Specify, wich fields have to be changed

clear l_sub_headerx_wa.

l_sub_headerx_wa-subauthgrp = true.

l_sub_headerx_wa-note = true.

l_sub_headerx_wa-subcharact = true.

append l_sub_headerx_wa to l_sub_headerx_tab.

  • Call BAPI_BUS1077_CHANGE

refresh l_return_tab.

call function 'BAPI_BUS1077_CHANGE'

exporting

flg_header = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

sub_headerx = l_sub_headerx_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_subheader'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CHANGE'

i_func_desc = text-005

i_spec_key = l_sub_header_wa-substance.

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_subheader'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_subheader'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

  • Call GETDETAIL in order to compare the actual identifier head with the expected one

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_subheader'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. "TEST_CHANGE_SUBHEADER

*----


*

method test_change_ident.

*This test changes the first identifier of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the identifier

  • was not changed properly.

  • List of properties that are changed:*

  • ID_TYPE = 'FRM'.

  • ID_CATEGRY = 'RAT'.

  • LANGU = 'E'.

  • IDENTIFIER = 'H2SO4'.

*----


*

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

  • Identifier specific data

data: l_ident_header_tab type standard table of bapi1077ri,

l_ident_header_wa like line of l_ident_header_tab,

l_ident_headerx_tab type standard table of bapisubrix,

l_ident_headerx_wa like line of l_ident_headerx_tab.

data: l_ident_record_no like l_ident_header_wa-record_no.

data: l_ident_longtext_tab type standard table of bapi1077il,

l_ident_longtext_wa like line of l_ident_longtext_tab.

data: l_ident_sublist_tab type standard table of bapi1077rl,

l_ident_sublist_wa like line of l_ident_sublist_tab.

*----


*

  • 1.1. create the default predefined SPECIFICATION & verify the creation *

*----


*

  • set the key date and the change number

addinf-valdat = '19651015'. "key date 10/15/1965

clear addinf-aennr. "change number

  • prepare the new specification head

clear l_sub_header_wa.

clear l_sub_header_tab.

*----


*

  • 2.1. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

*----


*

l_sub_header_wa-substance = spec_key. " Specification. key

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_ident = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.2. Prepare the data tables & call BAPI_BUS1077_CHANGE *

*----


*

clear l_ident_header_wa.

l_ident_header_wa-id_type = 'FRM'. "ident.'s type

l_ident_header_wa-id_categry = 'RAT'. "ident.'s category

l_ident_header_wa-identifier = 'H2SO4'. "#EC *

modify l_ident_header_tab from l_ident_header_wa index 1

transporting id_type

id_categry

langu

identifier

valid_from

valid_to

long_text.

  • Specify, wich fields have to be changed

clear l_ident_headerx_wa.

l_ident_headerx_wa-id_type = true.

l_ident_headerx_wa-id_categry = true.

l_ident_headerx_wa-langu = true.

l_ident_headerx_wa-identifier = true.

l_ident_headerx_wa-valid_from = true.

l_ident_headerx_wa-valid_to = true.

append l_ident_headerx_wa to l_ident_headerx_tab.

  • Change the identifier header

refresh l_return_tab.

call function 'BAPI_BUS1077_CHANGE'

exporting

flg_ident = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab

ident_headerx = l_ident_headerx_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CHANGE'

i_func_desc = text-005

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.3. Commit the data & remove locks *

*----


*

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.4. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

*----


*

  • Compare the actual identifier table with the expected table

  • Call GETDETAIL in order to compare the actual identifier head with the expected one

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_ident = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. " TEST_CHANGE_IDENT

*----


*

method test_change_ident_usage.

  • This test changes the identifier usage of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the identifier usage

  • was not changed properly.

  • List of properties that are changed:

  • RATING = 'PUBLIC'.

  • VAL_AREA = 'REG_WORLD'.

  • EXCL_IND = FALSE.

  • ACT_IND = TRUE.

*----


*

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

  • Identifier specific data

data: l_ident_header_tab type standard table of bapi1077ri,

l_ident_header_wa like line of l_ident_header_tab,

l_ident_headerx_tab type standard table of bapisubrix,

l_ident_headerx_wa like line of l_ident_headerx_tab.

data: l_ident_record_no like l_ident_header_wa-record_no.

data: l_ident_longtext_tab type standard table of bapi1077il,

l_ident_longtext_wa like line of l_ident_longtext_tab,

l_ident_longtextx_tab type standard table of bapisubilx,

l_ident_longtextx_wa like line of l_ident_longtextx_tab.

data: l_ident_sublist_tab type standard table of bapi1077rl,

l_ident_sublist_wa like line of l_ident_sublist_tab.

data: l_prop_usage_tab type standard table of bapi1077du,

l_prop_usage_wa like line of l_prop_usage_tab,

l_prop_usagex_tab type standard table of bapisubdux,

l_prop_usagex_wa like line of l_prop_usagex_tab.

data: l_prop_usage_buf1 like l_prop_usage_wa,

l_prop_usage_buf2 like l_prop_usage_wa.

  • prepare the new specification head

clear l_sub_header_wa.

clear l_sub_header_tab.

*----


*

  • 1.1. create the default predefined SPECIFICATION & verify the creation *

*----


*

  • set the key date and the change number

addinf-valdat = '19651015'. "key date 10/15/1965

clear addinf-aennr. "change number

  • prepare the new specification head

clear l_sub_header_wa.

clear l_sub_header_tab.

*----


*

  • 2.1. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

*----


*

l_sub_header_wa-substance = spec_key. "Specification. key

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_ident = true

flg_ident_longtext = true

flg_ident_usage = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab

ident_longtext = l_ident_longtext_tab

prop_usage = l_prop_usage_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_usage'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.2. Prepare the data tables & call BAPI_BUS1077_CHANGE *

*----


*

clear l_prop_usage_wa.

  • Prepare the usage

l_prop_usage_wa-mastertabl = 'ESTRI'.

l_prop_usage_wa-rating = 'PUBLIC'.

l_prop_usage_wa-val_area = 'REG_WORLD'.

l_prop_usage_wa-excl_ind = false.

l_prop_usage_wa-act_ind = true.

  • Modify the usage table

modify l_prop_usage_tab from l_prop_usage_wa index 1

transporting mastertabl

rating

val_area

excl_ind

act_ind.

  • Specify, wich fields have to be changed

clear l_prop_usagex_wa.

l_prop_usagex_wa-rating = true.

l_prop_usagex_wa-val_area = true.

l_prop_usagex_wa-excl_ind = true.

l_prop_usagex_wa-act_ind = true.

  • Append line to change table

append l_prop_usagex_wa to l_prop_usagex_tab.

  • Call BAPI_BUS1077_CHANGE

refresh l_return_tab.

call function 'BAPI_BUS1077_CHANGE'

exporting

flg_ident_usage = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab

prop_usage = l_prop_usage_tab

prop_usagex = l_prop_usagex_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_usage'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CHANGE'

i_func_desc = text-005

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.3. Commit the data & remove locks *

*----


*

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_usage'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_usage'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

  • prepare key date

addinf-valdat = '19651015'. "key date 10/15/1965

clear addinf-aennr. "change number

*----


*

  • 2.4. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

*----


*

  • Call GETDETAIL in order to compare the actual identifier USAGE with the expected one

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_ident = true

flg_ident_usage = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab

prop_usage = l_prop_usage_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_usage'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. " TEST_CHANGE_IDENT_USAGE.

*----


*

method test_change_prop_ftext.

  • This test changes the property ftext & longtext of a specification

  • Prerequisites: Created specification which

  • has these properties set. The test fails if the UD longtext

  • was not changed properly.

  • List of properties that are changed:

  • User defined text:

  • USRDFNDTXT = 'Changed user-defined text for ABAP Unit (LINE 1).'.

  • FORMAT_FLAG = TRUE.

  • UD_TXTTYPE = 'RM'. " Remark

  • LANGU = 'EN'.

  • LONG_TEXT = TRUE.

  • Four lines of the UD longtext are changed:

  • TEXT_LINE = 'Changed user-defined long text for ABAP Unit (LINE 1).'.

  • TEXT_LINE = 'Changed user-defined long text for ABAP Unit (LINE 2).'.

  • TEXT_LINE = 'Changed user-defined long text for ABAP Unit (LINE 3).'.

  • TEXT_LINE = 'Changed user-defined long text for ABAP Unit (LINE 4).'.

*----


*

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data: l_prop_data_tab type standard table of bapi1077pr,

l_prop_data_wa like line of l_prop_data_tab.

data: l_prop_component_tab type standard table of bapi1077vp,

l_prop_component_wa like line of l_prop_component_tab.

data: l_prop_componentx_tab type standard table of bapisubvpx,

l_prop_componentx_wa like line of l_prop_componentx_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

data: l_prop_ftext_tab type standard table of bapi1077df,

l_prop_ftext_wa like line of l_prop_ftext_tab,

l_prop_ftextx_tab type standard table of bapisubdfx,

l_prop_ftextx_wa like line of l_prop_ftextx_tab.

data l_prop_ftext_recn like l_prop_ftext_wa-record_no.

data: l_prop_ftext_longtext_tab type standard table of bapi1077fl,

l_prop_ftext_longtext_wa like line of l_prop_ftext_longtext_tab,

l_prop_ftextx_longtext_tab type standard table of bapisubflx,

l_prop_ftextx_longtext_wa like line of l_prop_ftextx_longtext_tab.

data: l_prop_usage_tab type standard table of bapi1077du,

l_prop_usage_wa like line of l_prop_usage_tab,

l_prop_usagex_tab type standard table of bapisubdux,

l_prop_usagex_wa like line of l_prop_usagex_tab.

data: l_prop_usage_buf1 like l_prop_usage_wa,

l_prop_usage_buf2 like l_prop_usage_wa.

  • set the key date and the change number

addinf-valdat = '19651015'. "key date 10/15/1965

clear addinf-aennr. "change number

  • prepare the new specification head

clear l_sub_header_wa.

clear l_sub_header_tab.

l_sub_header_wa-substance = spec_key.

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header for the GETDETAILS method

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Clear usage table & WA

clear: l_prop_usage_wa, l_prop_usage_tab.

l_prop_usage_wa-rating = 'PUBLIC'.

l_prop_usage_wa-val_area = 'REG_WORLD'.

l_prop_usage_wa-excl_ind = false.

append l_prop_usage_wa to l_prop_usage_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

flg_properties = true

flg_prop_details = true

flg_prop_ftext_longtext = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_data = l_prop_data_tab

prop_usage = l_prop_usage_tab

prop_component = l_prop_component_tab

prop_ftext = l_prop_ftext_tab

prop_ftext_longtext = l_prop_ftext_longtext_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_ftext'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • prepare the USER-DEFINED TEXTS tab

clear l_prop_ftext_wa.

l_prop_ftext_wa-usrdfndtxt = 'Changed user-defined text for ABAP Unit (LINE 1).'. "#EC NOTEXT

l_prop_ftext_wa-format_flag = true.

l_prop_ftext_wa-ud_txttype = 'RM'. " Remark

l_prop_ftext_wa-langu = 'EN'.

l_prop_ftext_wa-long_text = true.

  • Modify the UD texts tab

modify l_prop_ftext_tab from l_prop_ftext_wa index 1

transporting usrdfndtxt

format_flag

ud_txttype

langu

long_text.

  • prepare the TEXTS

clear l_prop_ftext_longtext_wa.

  • Prepare the 1-st text line

l_prop_ftext_longtext_wa-text_line = 'Changed user-defined long text for ABAP Unit (LINE 1).'. "#EC NOTEXT

l_prop_ftext_longtext_wa-format_col = '*'.

l_prop_ftext_longtext_wa-loglockmod = true.

modify l_prop_ftext_longtext_tab from l_prop_ftext_longtext_wa index 1

transporting text_line

format_col

loglockmod.

  • Prepare the 2-nd text line

l_prop_ftext_longtext_wa-text_line = 'Changed user-defined long text for ABAP Unit (LINE 2).'. "#EC NOTEXT

modify l_prop_ftext_longtext_tab from l_prop_ftext_longtext_wa index 2

transporting text_line

format_col

loglockmod.

  • Prepare the 3-rd text line

l_prop_ftext_longtext_wa-text_line = 'Changed user-defined long text for ABAP Unit (LINE 3).'. "#EC NOTEXT

modify l_prop_ftext_longtext_tab from l_prop_ftext_longtext_wa index 3

transporting text_line

format_col

loglockmod.

  • Specify, wich fields have to be changed

clear l_prop_ftextx_longtext_wa.

l_prop_ftextx_longtext_wa-text_line = true.

l_prop_ftextx_longtext_wa-format_col = true.

l_prop_ftextx_longtext_wa-loglockmod = true.

  • Append three equal lines to the change table

append l_prop_ftextx_longtext_wa to l_prop_ftextx_longtext_tab.

append l_prop_ftextx_longtext_wa to l_prop_ftextx_longtext_tab.

append l_prop_ftextx_longtext_wa to l_prop_ftextx_longtext_tab.

  • Set the change table for UD texts

clear l_prop_ftextx_wa.

  • L_PROP_FTEXTX_WA

l_prop_ftextx_wa-usrdfndtxt = true.

l_prop_ftextx_wa-ud_txttype = true.

l_prop_ftextx_wa-langu = true.

l_prop_ftextx_wa-long_text = true.

  • L_PROP_FTEXT_WA-UD_TXTTYPE

append l_prop_ftextx_wa to l_prop_ftextx_tab.

  • Change the UD texts & Longtexts

refresh l_return_tab.

call function 'BAPI_BUS1077_CHANGE'

exporting

flg_prop_ftext = true

flg_prop_ftext_longtext = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_ftext = l_prop_ftext_tab

prop_ftextx = l_prop_ftextx_tab

prop_ftext_longtext = l_prop_ftext_longtext_tab

prop_ftext_longtextx = l_prop_ftextx_longtext_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_ftext'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CHANGE'

i_func_desc = text-005

i_spec_key = l_sub_header_wa-substance.

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_ftext'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_ftext'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

  • Call GETDETAIL in order to compare the actual identifier longtext with the expected one

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

flg_properties = true

flg_prop_details = true

flg_prop_ftext_longtext = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_component = l_prop_component_tab

prop_ftext = l_prop_ftext_tab

prop_ftext_longtext = l_prop_ftext_longtext_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_ftext'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. "TEST_CHANGE_PROP_FTEXT

*----


*

method test_change_prop_usage.

  • This test changes the first property usage of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the property usage

  • was not changed properly.

  • List of properties that are changed:*

  • RATING = 'PUBLIC'.

  • VAL_AREA = 'REG_WORLD'.

  • EXCL_IND = FALSE.

  • ACT_IND = TRUE.

*----


*

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data: l_prop_data_tab type standard table of bapi1077pr,

l_prop_data_wa like line of l_prop_data_tab.

data: l_prop_component_tab type standard table of bapi1077vp,

l_prop_component_wa like line of l_prop_component_tab.

data: l_prop_componentx_tab type standard table of bapisubvpx,

l_prop_componentx_wa like line of l_prop_componentx_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

data: l_prop_usage_tab type standard table of bapi1077du,

l_prop_usage_wa like line of l_prop_usage_tab,

l_prop_usagex_tab type standard table of bapisubdux,

l_prop_usagex_wa like line of l_prop_usagex_tab.

data: l_prop_usage_buf1 like l_prop_usage_wa,

l_prop_usage_buf2 like l_prop_usage_wa.

  • set the key date and the change number

addinf-valdat = '19651015'. "key date 10/15/1965

clear addinf-aennr. "change number

  • prepare the new specification head

clear l_sub_header_wa.

clear l_sub_header_tab.

l_sub_header_wa-substance = spec_key.

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header for the GETDETAILS method

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Clear usage table & WA

clear: l_prop_usage_wa, l_prop_usage_tab.

l_prop_usage_wa-rating = 'PUBLIC'.

l_prop_usage_wa-val_area = 'REG_WORLD'.

l_prop_usage_wa-excl_ind = false.

append l_prop_usage_wa to l_prop_usage_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_properties = true

flg_prop_details = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_data = l_prop_data_tab

prop_usage = l_prop_usage_tab

prop_component = l_prop_component_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_usage'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • Prepare the usage

clear l_prop_usage_wa.

l_prop_usage_wa-rating = 'PUBLIC'.

l_prop_usage_wa-val_area = 'REG_EU'.

l_prop_usage_wa-mastertabl = 'ESTVA'.

l_prop_usage_wa-excl_ind = false.

l_prop_usage_wa-act_ind = true.

  • Modify the usage table

modify l_prop_usage_tab from l_prop_usage_wa index 1

transporting mastertabl

rating

val_area

excl_ind

act_ind.

  • Specify, wich fields have to be changed

clear l_prop_usagex_wa.

l_prop_usagex_wa-rating = true.

l_prop_usagex_wa-val_area = true.

l_prop_usagex_wa-excl_ind = true.

l_prop_usagex_wa-act_ind = true.

  • Append line to change table

append l_prop_usagex_wa to l_prop_usagex_tab.

  • Call BAPI_BUS1077_CHANGE

refresh l_return_tab.

call function 'BAPI_BUS1077_CHANGE'

exporting

flg_prop_usage = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_usage = l_prop_usage_tab

prop_usagex = l_prop_usagex_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_usage'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CHANGE'

i_func_desc = text-005

i_spec_key = l_sub_header_wa-substance.

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_usage'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_usage'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

  • Call GETDETAIL in order to compare the property usage with the expected one

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_properties = true

flg_prop_details = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_usage = l_prop_usage_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_usage'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. " TEST_CHANGE_PROP_USAGE.

*----


*

method test_change_ident_longtext.

  • This test changes the identifier longtext of a specification

  • Prerequisites: Created specification which

  • has this property set. The test fails if the identifier longtext

  • was not changed properly.

  • Four lines of the identifier longtext are changed:

  • TEXT_LINE = 'Changed long text for ABAP Unit (LINE 1).'.

  • TEXT_LINE = 'Changed long text for ABAP Unit (LINE 2).'.

  • TEXT_LINE = 'Changed long text for ABAP Unit (LINE 3).'.

  • TEXT_LINE = 'Changed long text for ABAP Unit (LINE 4).'.

*----


*

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data: l_prop_data_tab type standard table of bapi1077pr,

l_prop_data_wa like line of l_prop_data_tab.

data: l_prop_component_tab type standard table of bapi1077vp,

l_prop_component_wa like line of l_prop_component_tab.

data: l_prop_componentx_tab type standard table of bapisubvpx,

l_prop_componentx_wa like line of l_prop_componentx_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

  • Identifier specific data

data: l_ident_header_tab type standard table of bapi1077ri,

l_ident_header_wa like line of l_ident_header_tab,

l_ident_headerx_tab type standard table of bapisubrix,

l_ident_headerx_wa like line of l_ident_headerx_tab.

data: l_ident_record_no like l_ident_header_wa-record_no.

data: l_ident_longtext_tab type standard table of bapi1077il,

l_ident_longtext_wa like line of l_ident_longtext_tab,

l_ident_longtextx_tab type standard table of bapisubilx,

l_ident_longtextx_wa like line of l_ident_longtextx_tab.

data: l_ident_sublist_tab type standard table of bapi1077rl,

l_ident_sublist_wa like line of l_ident_sublist_tab.

data: l_prop_usage_tab type standard table of bapi1077du,

l_prop_usage_wa like line of l_prop_usage_tab.

data: l_prop_usage_buf1 like l_prop_usage_wa,

l_prop_usage_buf2 like l_prop_usage_wa.

  • prepare the new specification head

clear l_sub_header_wa.

clear l_sub_header_tab.

*----


*

  • 2.1. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

*----


*

l_sub_header_wa-substance = spec_key. " Specification. key

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header for the GETDETAILS method

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

flg_ident = true

flg_ident_longtext = true

flg_ident_usage = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab

ident_longtext = l_ident_longtext_tab

prop_usage = l_prop_usage_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_longtext'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.2. Prepare the data tables & call BAPI_BUS1077_CHANGE *

*----


*

clear l_ident_longtext_wa.

  • Prepare identifier longtext line 1

l_ident_longtext_wa-text_line = 'Changed long text for ABAP Unit (LINE 1).'. "#EC NOTEXT

l_ident_longtext_wa-format_col = '*'.

l_ident_longtext_wa-loglockmod = true.

modify l_ident_longtext_tab from l_ident_longtext_wa index 1

transporting text_line

format_col

loglockmod.

  • Prepare identifier longtext line 2

l_ident_longtext_wa-primarykey = 212. "int. key

l_ident_longtext_wa-text_line = 'Changed long text for ABAP Unit (LINE 2).'. "#EC NOTEXT

modify l_ident_longtext_tab from l_ident_longtext_wa index 2

transporting text_line

format_col

loglockmod.

  • Prepare identifier longtext line 3

l_ident_longtext_wa-primarykey = 213. "int. key

l_ident_longtext_wa-text_line = 'Changed long text for ABAP Unit (LINE 3).'. "#EC NOTEXT

modify l_ident_longtext_tab from l_ident_longtext_wa index 3

transporting text_line

format_col

loglockmod.

  • Prepare identifier longtext line 4

l_ident_longtext_wa-primarykey = 214. "int. key

l_ident_longtext_wa-text_line = 'Changed long text for ABAP Unit (LINE 4).'. "#EC NOTEXT

modify l_ident_longtext_tab from l_ident_longtext_wa index 4

transporting text_line

format_col

loglockmod.

  • Specify, wich fields have to be changed

clear l_ident_longtextx_wa.

l_ident_longtextx_wa-text_line = true.

l_ident_longtextx_wa-format_col = true.

l_ident_longtextx_wa-loglockmod = true.

  • Append four equal lines

append l_ident_longtextx_wa to l_ident_longtextx_tab.

append l_ident_longtextx_wa to l_ident_longtextx_tab.

append l_ident_longtextx_wa to l_ident_longtextx_tab.

append l_ident_longtextx_wa to l_ident_longtextx_tab.

refresh l_return_tab.

call function 'BAPI_BUS1077_CHANGE'

exporting

flg_ident_longtext = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_longtext = l_ident_longtext_tab

ident_longtextx = l_ident_longtextx_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_longtext'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CHANGE'

i_func_desc = text-005

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.3. Commit the data & remove locks *

*----


*

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_longtext'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_longtext'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

  • Call GETDETAIL in order to compare the actual identifier longtext with the expected one

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

flg_ident = true

flg_ident_longtext = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

ident_header = l_ident_header_tab

ident_longtext = l_ident_longtext_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_ident_longtext'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. " TEST_CHANGE_IDENT_LONGTEXT

*----


*

method test_read_usage_filter.

  • This test assures that the usage filter is working properly

  • Prerequisites: Created specification which:

  • - Has property usage set to PUBLIC/EU or PUBLIC/REG_WORLD.

  • This test has two scenarios:

  • 1-st:

  • Read the value assignments with filter which should not find

  • any value assignments matching the criteria.

  • Criteria: INTERNAL/REG_WORLD

  • 2-nd:

  • Read the value assignments with filter which should find

  • one value assignment matching the criteria.

  • Criteria: PUBLIC/ES

*----


*

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data: l_prop_data_tab type standard table of bapi1077pr,

l_prop_data_wa like line of l_prop_data_tab.

data: l_prop_componentx_tab type standard table of bapisubvpx,

l_prop_componentx_wa like line of l_prop_componentx_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

data: l_prop_usage_tab type standard table of bapi1077du,

l_prop_usage_wa like line of l_prop_usage_tab,

l_prop_usagex_tab type standard table of bapisubdux,

l_prop_usagex_wa like line of l_prop_usagex_tab.

*----


*

  • First scenario, no value assignments should be found *

*----


*

  • Prepare the new specification head

clear l_sub_header_wa.

clear l_sub_header_tab.

l_sub_header_wa-substance = spec_key. "Specification. key

  • Fill input sub_header tab

refresh l_sub_header_tab.

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header for the GETDETAILS method

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Clear usage table & WA

clear: l_prop_usage_wa, l_prop_usage_tab.

  • Set the usage filter

l_prop_usage_wa-rating = 'INTERNAL'.

l_prop_usage_wa-val_area = 'REG_WORLD'.

l_prop_usage_wa-excl_ind = false.

l_prop_usage_wa-act_ind = true.

append l_prop_usage_wa to l_prop_usage_tab.

  • Call GETDETAIL in order to obtain the value assignments according to the filter

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_prop_details = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_usage = l_prop_usage_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

clear l_return_wa.

  • Check if there's an error message that no VA were found with the specified key

read table l_return_tab

with key

id = 'D9'

number = '356'

into l_return_wa.

*----


*

  • Second scenario, one value assignment should be found *

*----


*

clear l_sub_header_wa.

refresh l_sub_header_tab.

refresh l_prop_header_tab.

l_sub_header_wa-substance = spec_key. "Specification. key

  • Fill input sub_header tab

refresh l_sub_header_tab.

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header for the GETDETAILS method

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Clear usage table & WA

clear: l_prop_usage_wa, l_prop_usage_tab.

  • Set the usage filter

l_prop_usage_wa-rating = 'PUBLIC'.

l_prop_usage_wa-val_area = 'ES'.

l_prop_usage_wa-excl_ind = false.

l_prop_usage_wa-act_ind = true.

append l_prop_usage_wa to l_prop_usage_tab.

  • Call GETDETAIL in order to obtain the value assignments according to the filter

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_prop_details = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_usage = l_prop_usage_tab

prop_val = l_prop_val_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_read_usage_filter'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. "TEST_READ_USAGE_FILTER

*----


*

method test_ref_subs.

  • This test's purpose is to assure that specification references

  • can be created successfully.

  • Scenario:

  • 1. Create 2 specifications(one with property values set, the other without)

  • 2. Create a reference from the second spec to the first

  • 3. Verify that the specifications have at least one property which

  • is the same - this will assure that the reference has been

  • created successfully

*----


*

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_refsub_tab type standard table of bapi1077rr,

l_refsub_wa like line of l_refsub_tab.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data: l_prop_data_tab type standard table of bapi1077pr,

l_prop_data_wa like line of l_prop_data_tab.

data: l_prop_component_tab type standard table of bapi1077vp,

l_prop_component_wa like line of l_prop_component_tab,

l_prop_componentx_tab type standard table of bapisubvpx,

l_prop_componentx_wa like line of l_prop_componentx_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

data: l_refsubs_tab type standard table of bapi1077rr,

l_refsubs_wa like line of l_refsubs_tab.

data: record_no_wa type eserecn,

record_no_pre_wa type eserecn.

*----


*

  • Read the record number of the reference substance *

*----


*

  • Prepare the Sub header tab

clear l_sub_header_wa.

refresh l_sub_header_tab.

l_sub_header_wa-substance = spec_key.

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Call GETDETAIL in order to obtain the spec. RECORD_NO

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_ref_subs'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • Read the record number

read table l_sub_header_tab

into l_sub_header_wa

index 1

transporting record_no.

record_no_wa = l_sub_header_wa-record_no.

*----


*

  • Read the record number of the referenced substance-*

*----


*

clear l_sub_header_wa.

refresh l_sub_header_tab.

  • Prepare the Sub header tab

l_sub_header_wa-substance = spec_key_pre.

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Get the spec_key RECORD_NO

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_ref_subs'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • Read the record number

read table l_sub_header_tab

into l_sub_header_wa

index 1

transporting record_no.

record_no_pre_wa = l_sub_header_wa-record_no.

*----


*

  • Call Getdetail in order to obtain the subheader *

  • of the referenced substance. *

*----


*

  • Clear the table & WA

clear l_sub_header_wa.

clear l_sub_header_tab.

  • Set the specification key

l_sub_header_wa-substance = spec_key_pre. "Specification key of referenced substance

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header for the GETDETAILS method

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Call GETDETAIL in order to obtain the needed data(Substance header)

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_ref_subs'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • Prepare the data for the creation of ref sub

  • Clear wa

clear l_refsubs_wa.

refresh l_refsubs_tab.

l_refsubs_wa-primarykey = 2908. "int. key

l_refsubs_wa-flgprimkey = true.

l_refsubs_wa-foreignkey = record_no_pre_wa.

l_refsubs_wa-flgfrgnkey = false.

l_refsubs_wa-ref_recnrh = record_no_wa.

append l_refsubs_wa to l_refsubs_tab.

  • Call the create module

refresh l_return_tab.

call function 'BAPI_BUS1077_CREATE'

exporting

flg_refsubs = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

refsubs = l_refsubs_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_ref_subs'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CREATE'

i_func_desc = text-000

i_spec_key = l_sub_header_wa-substance.

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_ref_subs'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_ref_subs'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

*----


*

  • GetDetail for original Substance *

*----


*

clear l_sub_header_wa.

refresh l_sub_header_tab.

l_sub_header_wa-substance = spec_key. " Specification. key

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header for the GETDETAILS method

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

flg_properties = true

flg_prop_data = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_data = l_prop_data_tab

prop_component = l_prop_component_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_ref_subs'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

*----


*

  • GetDetail for referenced Substance *

*----


*

clear l_sub_header_wa.

refresh l_sub_header_tab.

l_sub_header_wa-substance = spec_key_pre. " Specification. key

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header for the GETDETAILS method

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

flg_properties = true

flg_prop_data = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_data = l_prop_data_tab

prop_component = l_prop_component_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_ref_subs'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. " TEST_REF_SUBS

*----


*

method test_change_comp.

*This test changes the first component in the property

*"Exact composition based on compound"

  • Prerequisites: Created specification which

  • has this property set. The test fails if the component's data

  • was not changed properly.

  • List of properties that are changed:

  • COMPCAT = 'EMULSIFIER'.

  • OPLOWLIMIT = '>'.

  • LOW_LIMIT = '0.15'.

  • OPUPPLIMIT = '<='.

  • UPP_LIMIT = '0.88'.

  • AVG_VAL = '0.88'.

  • EXPONENT = 'PPM'.

*----


*

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data: l_prop_data_tab type standard table of bapi1077pr,

l_prop_data_wa like line of l_prop_data_tab.

data: l_prop_component_tab type standard table of bapi1077vp,

l_prop_component_wa like line of l_prop_component_tab.

data: l_prop_componentx_tab type standard table of bapisubvpx,

l_prop_componentx_wa like line of l_prop_componentx_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

*----


*

  • 1.1. create the default predefined SPECIFICATION & verify the creation *

*----


*

  • set the key date and the change number

addinf-valdat = '19651015'. "key date 10/15/1965

clear addinf-aennr. "change number

  • prepare the new specification head

clear l_sub_header_wa.

clear l_sub_header_tab.

*----


*

  • 2.1. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

*----


*

l_sub_header_wa-substance = spec_key. " Specification. key

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header for the GETDETAILS method

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_properties = true

flg_prop_data = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_data = l_prop_data_tab

prop_component = l_prop_component_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_comp'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.2. Prepare the data tables & call BAPI_BUS1077_CHANGE *

*----


*

  • CLEAR PROP_COMPONENT_WA.

clear l_prop_component_wa.

l_prop_component_wa-compcat = 'EMULSIFIER'.

l_prop_component_wa-oplowlimit = '>'.

l_prop_component_wa-low_limit = '0.15'.

l_prop_component_wa-opupplimit = '<='.

l_prop_component_wa-upp_limit = '0.88'.

l_prop_component_wa-avg_val = '0.88'.

l_prop_component_wa-exponent = 'PPM'.

modify l_prop_component_tab from l_prop_component_wa index 1

transporting compcat

oplowlimit

low_limit

opupplimit

upp_limit

avg_val

exponent.

  • Specify, wich fields have to be changed

clear l_prop_componentx_wa.

l_prop_componentx_wa-compcat = true.

l_prop_componentx_wa-oplowlimit = true.

l_prop_componentx_wa-low_limit = true.

l_prop_componentx_wa-opupplimit = true.

l_prop_componentx_wa-upp_limit = true.

l_prop_componentx_wa-avg_val = true.

l_prop_componentx_wa-exponent = true.

append l_prop_componentx_wa to l_prop_componentx_tab.

  • Call the BAPI_BUS1077_CHANGE method

refresh l_return_tab.

call function 'BAPI_BUS1077_CHANGE'

exporting

flg_prop_comp = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_component = l_prop_component_tab

prop_componentx = l_prop_componentx_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_comp'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CHANGE'

i_func_desc = text-005

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.3. Commit the data & remove locks *

*----


*

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_comp'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_comp'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.4. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

*----


*

refresh l_return_tab.

  • Call GETDETAIL in order to compare the actual component table with the expected one

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

flg_properties = true

flg_prop_data = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_component = l_prop_component_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_comp'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. " TEST_CHANGE

*----


*

method test_change_assessment.

  • This test changes the assessment of the property usage of a specification

  • Prerequisites: Created specification which:

  • - Has the predefined dafault property set. The test fails if the property assessment

  • don't change properly.

  • - List of properties that are changed:

  • ASSESSMENT = '2'.

*----


*

  • Local data

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data: l_prop_assess_tab type standard table of bapi1077dr,

l_prop_assess_wa like line of l_prop_assess_tab.

data: l_prop_assessx_tab type standard table of bapisubdrx,

l_prop_assessx_wa like line of l_prop_assessx_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

  • ----------------------------

  • 1.1. create the default predefined SPECIFICATION & verify the creation

  • ----------------------------

  • Set the key date and the change number

addinf-valdat = '19651015'. "key date 10/15/1965

clear addinf-aennr. "change number

  • ----------------------------

  • 2.1. Prepare the data tables & call BAPI_BUS1077_GETDETAIL

  • ----------------------------

  • Prepare the specification header

refresh l_sub_header_tab.

clear l_sub_header_wa.

l_sub_header_wa-substance = spec_key.

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header

refresh l_prop_header_tab.

clear l_prop_header_wa.

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Prepare the assessment data

refresh: l_prop_assess_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

scenario = '1'

change_number = addinf-aennr

flg_header = true

flg_properties = true

flg_prop_details = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_reliability = l_prop_assess_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_assessment'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • ----------------------------

  • 2.2. Prepare the data tables & call BAPI_BUS1077_CHANGE

  • ----------------------------

  • Prepare the new data for ASSESSMENT tab

clear l_prop_assess_wa.

l_prop_assess_wa-assessment = '2'.

  • Modify the ASSESMENT table

modify l_prop_assess_tab from l_prop_assess_wa index 1

transporting assessment.

  • Specify, wich fields have to be changed

refresh l_prop_assessx_tab.

clear l_prop_assessx_wa.

l_prop_assessx_wa-assessment = true.

append l_prop_assessx_wa to l_prop_assessx_tab.

  • Call BAPI_BUS1077_CHANGE

refresh l_return_tab.

call function 'BAPI_BUS1077_CHANGE'

exporting

flg_prop_rel = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_reliability = l_prop_assess_tab

prop_reliabilityx = l_prop_assessx_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_assessment'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CHANGE'

i_func_desc = text-005

i_spec_key = l_sub_header_wa-substance.

  • ----------------------------

  • 2.3. Commit the data & remove locks

  • ----------------------------

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_assessment'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_assessment'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

  • ----------------------------

  • 2.4. Prepare the data tables & call BAPI_BUS1077_GETDETAIL

  • ----------------------------

  • Call GETDETAIL in order to compare the property usage with the expected one

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

scenario = '1'

change_number = addinf-aennr

flg_header = true

flg_properties = true

flg_prop_details = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_reliability = l_prop_assess_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_assessment'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. " TEST_CHANGE_ASSESSMENT.

*----


*

method test_change_prop_data.

  • This test changes the property data of a value assignment

  • Prerequisites: Created specification which:

  • - Has the predefined dafault property set. The test fails if the property data

  • doesn't change properly.

  • - Changed data:

  • CHAR_VALUE = 'ABAP UNIT - Change text'.

*----


*

  • Local data

data: l_estva_tab type standard table of estva.

data: l_estva_wa like line of l_estva_tab.

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_prop_header_tab type standard table of bapi1077vh,

l_prop_header_wa like line of l_prop_header_tab.

data: l_prop_val_tab type standard table of bapi1077va,

l_prop_val_wa like line of l_prop_val_tab.

data: l_prop_data_tab type standard table of bapi1077pr,

l_prop_data_wa like line of l_prop_data_tab.

data: l_prop_datax_tab type standard table of bapisubprx,

l_prop_datax_wa like line of l_prop_datax_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

data: record_no_wa type eserecn.

data: record_no_pre_wa type eserecn.

data: l_phrase_id(30) type c.

*----


*

  • 1.1. create the default predefined SPECIFICATION & verify the creation *

*----


*

  • Set the key date and the change number

addinf-valdat = '19651015'. "key date 10/15/1965

clear addinf-aennr. "change number

  • Class_setup...

*----


*

  • 2.1. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

  • Modify the changed date & person in ESTVA *

  • before we modify the value assignment data *

*----


*

  • Prepare the Sub header tab

clear l_sub_header_wa.

refresh l_sub_header_tab.

l_sub_header_wa-substance = spec_key.

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Call GETDETAIL in order to obtain the spec. RECORD_NO

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

flg_header = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_data'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • Read the record number

read table l_sub_header_tab

into l_sub_header_wa

index 1

transporting record_no.

record_no_wa = l_sub_header_wa-record_no.

select * from estva

into l_estva_wa

where

recnroot = record_no_wa.

endselect.

l_estva_wa-upddat = '19651015'.

l_estva_wa-updnam = 'Someone'. "#EC NOTEXT

modify estva from l_estva_wa.

*----


*

  • End ESTVA Modification *

*----


*

*----


*

  • 2.3. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

*----


*

  • Prepare the specification header

refresh l_sub_header_tab.

refresh l_prop_header_tab.

clear l_sub_header_wa.

l_sub_header_wa-substance = spec_key.

append l_sub_header_wa to l_sub_header_tab.

  • Prepare the property header

refresh l_prop_header_tab.

clear l_prop_header_wa.

l_prop_header_wa-subchacat = 'SAP_EHS_1012_015'. " Chemical characterization

append l_prop_header_wa to l_prop_header_tab.

  • Prepare the assessment data

refresh: l_prop_data_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

scenario = '1'

change_number = addinf-aennr

flg_header = true

flg_properties = true

flg_prop_data = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_data = l_prop_data_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_data'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.4. Prepare the data tables & call BAPI_BUS1077_CHANGE *

*----


*

  • Get random phrase-text

call method get_random_phrase

exporting

i_phrase_sel_set = 'SAP_EHS_1012_015_REMARK'

importing

e_phrase_id = l_phrase_id.

  • Prepare the new data for L_PROP_DATA_TAB

clear l_prop_data_wa.

l_prop_data_wa-char_value = l_phrase_id.

  • Modify the ASSESMENT table

modify l_prop_data_tab from l_prop_data_wa index 1

transporting char_value.

  • Specify, wich fields have to be changed

refresh l_prop_datax_tab.

clear l_prop_datax_wa.

l_prop_datax_wa-char_value = true.

append l_prop_datax_wa to l_prop_datax_tab.

  • Call BAPI_BUS1077_CHANGE

refresh l_return_tab.

call function 'BAPI_BUS1077_CHANGE'

exporting

flg_prop_data = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_data = l_prop_data_tab

prop_datax = l_prop_datax_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_data'

i_tab_flg = true

i_func = 'BAPI_BUS1077_CHANGE'

i_func_desc = text-005

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.5. Commit the data & remove locks *

*----


*

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_data'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_data'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

*----


*

  • 2.6. Prepare the data tables & call BAPI_BUS1077_GETDETAIL *

*----


*

  • Call GETDETAIL in order to compare the property usage with the expected one

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

scenario = '1'

change_number = addinf-aennr

flg_header = true

flg_properties = true

flg_prop_data = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

prop_header = l_prop_header_tab

prop_val = l_prop_val_tab

prop_data = l_prop_data_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_change_prop_data'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. " TEST_CHANGE_PROP_DATA.

*----


*

method test_del_ref.

*This test deletes the reference specification

  • Prerequisites: specification with a reference süecification.

*----


*

data: l_sub_header_tab type standard table of bapi1077rh,

l_sub_header_wa like line of l_sub_header_tab.

data: l_return_tab type standard table of bapiret2,

l_return_wa like line of l_return_tab.

data: l_refsubs_tab type standard table of bapi1077rr,

l_refsubs_wa like line of l_refsubs_tab,

l_refsubsx_tab type standard table of bapisubrrx,

l_refsubsx_wa like line of l_refsubsx_tab.

data: record_no_wa type eserecn,

record_no_pre_wa type eserecn.

  • set the key date and the change number

addinf-valdat = '19651015'. "key date 10/15/1965

clear addinf-aennr. "change number

  • prepare the new specification head

clear l_sub_header_wa.

clear l_sub_header_tab.

l_sub_header_wa-substance = spec_key_pre.

  • Fill input sub_header tab

append l_sub_header_wa to l_sub_header_tab.

  • Call GETDETAIL in order to obtain the needed data

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_refsubs = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

refsubs = l_refsubs_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_ta

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_del_ref'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

  • Delete Reference

refresh l_return_tab.

call function 'BAPI_BUS1077_DELETE'

exporting

flg_refsubs = true

tables

return = l_return_tab

sub_header = l_sub_header_tab

refsubs = l_refsubs_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_del_ref'

i_tab_flg = false

i_func = 'BAPI_BUS1077_DELETE'

i_func_desc = text-004

i_spec_key = l_sub_header_wa-substance.

  • commit work sy-subrc

clear l_return_wa.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = true

importing

return = l_return_wa.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_del_ref'

i_tab_flg = false

i_func = 'BAPI_TRANSACTION_COMMIT'

i_func_desc = text-001

i_spec_key = l_sub_header_wa-substance.

  • remove locks (according to note 732628)

refresh l_return_tab.

call function 'BAPI_BUS1077_SAVEFROMBUFFER'

exporting

flg_luw_close_for_bapi = true

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_del_ref'

i_tab_flg = true

i_func = 'BAPI_BUS1077_SAVEFROMBUFFER'

i_func_desc = text-002

i_spec_key = l_sub_header_wa-substance.

  • Call GETDETAIL in order to compare the property usage with the expected one

refresh l_return_tab.

call function 'BAPI_BUS1077_GETDETAIL'

exporting

key_date = addinf-valdat

change_number = addinf-aennr

flg_header = true

flg_refsubs = true

scenario = '1'

tables

return = l_return_tab

sub_header = l_sub_header_tab

refsubs = l_refsubs_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • clear buffer

refresh l_return_tab.

call function 'BAPI_BUS1077_CLEARBUFFER'

tables

return = l_return_tab.

  • If errors occured, write them into l_dis_tab

call method set_dis_tab

exporting

i_table = l_return_tab

i_wa = l_return_wa

i_meth = 'test_del_ref'

i_tab_flg = true

i_func = 'BAPI_BUS1077_GETDETAIL'

i_func_desc = text-003

i_spec_key = l_sub_header_wa-substance.

endmethod. " TEST_DEL_REF

*----


*

method set_dis_tab.

  • This method adds a line to the displayed table

*----


*

data:

l_wa like line of i_table.

if i_tab_flg = true.

loop at i_table into l_wa.

if l_wa-type <> 'S' and

l_wa-type <> 'I'.

call method set_dis_wa

exporting

i_meth_wa = i_meth

i_func_wa = i_func

i_func_desc_wa = i_func_desc

i_error_desc_wa = l_wa-message

i_spec_key_wa = i_spec_key.

append l_dis_wa to l_dis_tab.

endif.

endloop.

else.

if i_wa is not initial.

if i_wa-type <> 'S' and

i_wa-type <> 'I'.

call method set_dis_wa

exporting

i_meth_wa = i_meth

i_func_wa = i_func

i_func_desc_wa = i_func_desc

i_error_desc_wa = i_wa-message

i_spec_key_wa = i_spec_key.

append l_dis_wa to l_dis_tab.

endif.

endif.

endif.

endmethod. " set_dis_tab

*----


*

method get_dis_tab.

  • This method returns the displayed table

*----


*

e_dis_tab = l_dis_tab.

endmethod. " set_dis_tab

*----


*

method set_dis_wa.

  • This method sets values of the workarea "l_dis_wa"

*----


*

l_dis_wa-meth = i_meth_wa.

l_dis_wa-func = i_func_wa.

l_dis_wa-func_desc = i_func_desc_wa.

l_dis_wa-error_desc = i_error_desc_wa.

l_dis_wa-spec_key = i_spec_key_wa.

endmethod. " set_dis_wa

*----


*

method get_dis_wa.

  • This method sets values of the workarea "l_dis_wa"

*----


*

e_meth_wa = l_dis_wa-meth.

e_func_wa = l_dis_wa-func.

e_func_desc_wa = l_dis_wa-func_desc.

e_error_desc_wa = l_dis_wa-error_desc.

e_spec_key_wa = l_dis_wa-spec_key.

endmethod. " get_dis_wa

*----


*

method get_random_matnr.

  • This method gets materialnumber of the first entry in the table "MAKT"

*----


*

select single matnr "#EC CI_NOFIELD

from makt

into e_mat_nr

where matnr ne ''.

endmethod. " get_random_matnr

*----


*

method get_random_source.

  • This method gets a random source-id

*----


*

select single srcid

from tcg46

into e_source

where srcid ne ''.

endmethod. " get_random_source

*----


*

method get_random_phrase.

  • This method gets a random phrase to a give phrase selection set

*----


*

types:

begin of l_phr_id_cat_type_rec,

phrid(15) type c,

catpin(5) type c,

end of l_phr_id_cat_type_rec.

data:

l_phr_id_cat_tab type table of l_phr_id_cat_type_rec,

l_phr_id_cat_wa like line of l_phr_id_cat_tab.

data:

recn_phr_sel_set(20) type c,

recn_ph(20) type c.

  • Get ID for given phrase selection set

select single recn

from estps

into recn_phr_sel_set

where phrsel eq i_phrase_sel_set.

select single recntph

from estpj

into recn_ph

where recntps eq recn_phr_sel_set

and delflg eq false.

select single phrid catpin

from estph

into corresponding fields of l_phr_id_cat_wa

where recn eq recn_ph and

delflg eq false.

concatenate l_phr_id_cat_wa-catpin '-' l_phr_id_cat_wa-phrid

into e_phrase_id.

endmethod. " get_random_phrase

*----


*

method write_table_to_list.

  • writes a table to to the list

*----


*

data:

only_harmless_mesg(1) type c value true.

leave to list-processing.

set pf-status space.

skip.

write: i_method color 3.

new-line.

write at /1(172) sy-uline.

new-line.

  • Headlines for cols

write: sy-vline no-gap,

at (32) 'Function' "#EC NOTEXT

color 1 on left-justified no-gap.

write: sy-vline no-gap,

at (32) 'Function description' "#EC NOTEXT

color 1 on left-justified no-gap.

write: sy-vline no-gap,

at (80) 'Error description' "#EC NOTEXT

color 1 on left-justified no-gap.

write: sy-vline no-gap,

at (24) 'Specification key' "#EC NOTEXT

color 1 on left-justified no-gap.

write: sy-vline.

write at /1(172) sy-uline.

new-line.

clear l_dis_wa.

  • Write table to list

if i_dis_tab is not initial.

loop at i_dis_tab into l_dis_wa.

only_harmless_mesg = false.

write: sy-vline no-gap, at (32) l_dis_wa-func no-gap.

write: sy-vline no-gap, at (32) l_dis_wa-func_desc no-gap.

write: sy-vline no-gap, at (80) l_dis_wa-error_desc no-gap.

write: sy-vline no-gap, at (24) l_dis_wa-spec_key no-gap.

write sy-vline.

new-line.

endloop.

if only_harmless_mesg = true.

write: sy-vline no-gap, at (100) text-006 no-gap.

write at 173 sy-vline.

endif.

write at /1(172) sy-uline.

else.

write: sy-vline no-gap, at (100) text-006 no-gap.

write at 173 sy-vline.

write at /1(172) sy-uline.

endif.

endmethod. " write_table_to_list

endclass. "lcl_BUS1077_change_test IMPLEMENTATION

*&----


*

*& PBO and PAI for Dynpro 100

*&----


*

module pbo_100 output.

set pf-status 'MAIN100'.

set titlebar '100_TITLE'.

  • Check every table if errors occured. If no errors occured,

  • Fill with hint "No errors occured"

if lg_dis_tab is initial.

lg_dis_wa-meth = text-012.

append lg_dis_wa to lg_dis_tab.

endif.

  • Table 1: test_cr_all_spec_dtls_bylrs

create object g_custom_container

exporting container_name = g_container_1.

create object grid1

exporting i_parent = g_custom_container.

call method grid1->set_table_for_first_display

changing

it_outtab = lg_dis_tab

it_fieldcatalog = lg_fcat_tab.

endmodule.

module pai_100 input.

  • to react on oi_custom_events:

call method cl_gui_cfw=>dispatch.

case ok_code.

when 'EXIT'.

leave program.

when 'BACK'.

leave program.

when '%EX'.

leave program.

when 'RW'.

leave program.

when others.

  • do nothing

endcase.

clear ok_code.

endmodule.

0 Kudos

Hi Johnson,

could you please share me code details for value assignment in bapi_bus1077_create.

I am facing issue here,

My requirement is to create a specification and assign value assignment in remarks fiels.

I am able to create a specification but cant able to assign value assignment .

Kindly help me on the same.

Regards,

Vinoth.