on 05-12-2011 7:17 AM
Hi all,
I use this code to add possible hazards properties.
CLEAR l_prop_header_wa.
header_primkey = header_primkey + 1.
l_prop_header_wa-primarykey = header_primkey. "int. key
l_prop_header_wa-flgprimkey = abap_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_1011_001'. " POSSIBLE_HAZARDS
APPEND l_prop_header_wa TO l_prop_header_tab.
LOOP AT lt_estpp INTO ls_estpp.
SELECT * FROM estpp INTO estpp_wa
WHERE langu = sy-langu
AND phrtext = ls_estpp-phrtext.
SELECT * FROM estph INTO estph_wa
WHERE recn = estpp_wa-recnroot.
CONCATENATE estph_wa-catpin '-' estph_wa-phrid INTO l_prop_data_wa-char_value.
* prepare the VALUE tab
CLEAR l_prop_val_wa.
val_primkey = val_primkey + 1.
l_prop_val_wa-primarykey = val_primkey.
l_prop_val_wa-flgprimkey = abap_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.
CLEAR l_prop_data_wa.
data_primkey = data_primkey + 1.
l_prop_data_wa-primarykey = data_primkey.
l_prop_data_wa-flgprimkey = abap_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-name_char = 'SAP_EHS_1011_001_ADVICE'.
l_prop_data_wa-oper_inc = 0.
APPEND l_prop_data_wa TO l_prop_data_tab.
CLEAR l_prop_data_wa.
ENDSELECT.
ENDSELECT.
ENDLOOP.
I don't know why it doesn't work.
When i call the bapi 'BAPI_BUS1077_CREATE', I have no error message.
But when i check within CG02 transaction i have nothing.
I mean i have a new entry but there is no new "Possible Hazards" property.
Does someone see an error in this code ?
Thanks in advance for your help.
Hi experts,
Anyone can help me please to resolve this issue or can send me or post an example of source code doing this to compare it with mine.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
if i remember correct the property (value assignment) "possible hazards" and the characteristic your are using is "phrase" based
In your statements your are "searching" for some phrases
SELECT * FROM estpp INTO estpp_wa
WHERE langu = sy-langu
AND phrtext = ls_estpp-phrtext.
SELECT * FROM estph INTO estph_wa
WHERE recn = estpp_wa-recnroot.
CONCATENATE estph_wa-catpin '-' estph_wa-phrid INTO l_prop_data_wa-char_value.
But you do not "populate" the characteristic (if I read correct your code) (if found no further use of estph_wa
in your code )
Furthermore: the "surface" forces you to specify "assessment". Normally you need to populate tthis too in your code.
Futhermore I have the feeling that your "loop/endloop" statement is a further problem. I am not an expert of this BAPI but
there are "two" options:
a.) you create more than one value assignment in the property
b.) or you use the same value assignmnet and populate the charceteristice with more than one value
I belive this is what you would like to achieve. I am not sure that your code will work like that.,
So: what is the content of ls_estpp-phrtext?
Furthermore I have the feeling that you do not perfomr "error" handling. Than means: what shoul "happen" if the select does retrieve "zero" lines (no value found)?
Furtheremore in your code theer is no check (or it is not shown in the code in this thread) regarding the phrase set which is linked to the characteristic.
Please refer to further threads in this FORUM. They provide an OSS note in which exmaple programs of the use of these BAPIS are delivered.
With best regards
C.B.
PS: I belive there is a major logic error in youre code. First you populate the necessary table but before you add it you clear the table therefore it is empty. Therefore nothing can happen.
Edited by: Christoph Bergemann on May 13, 2011 9:51 PM
Edited by: Christoph Bergemann on May 13, 2011 9:52 PM
Edited by: Christoph Bergemann on May 13, 2011 9:56 PM
Edited by: Christoph Bergemann on May 13, 2011 9:57 PM
Edited by: Christoph Bergemann on May 13, 2011 9:59 PM
Edited by: Christoph Bergemann on May 13, 2011 10:01 PM
Edited by: Christoph Bergemann on May 13, 2011 10:18 PM
Edited by: Christoph Bergemann on May 13, 2011 10:19 PM
Edited by: Christoph Bergemann on May 13, 2011 10:21 PM
Hi Christoph,
Thanks a lot for your response.
I added all these "Select statement" to retreive the phrase's code chosen by the user.
I removed the "clear" of prop_data. Effectively, It was a mistake.
And i checked all values in the dubug mode.
It seems to be ok.
I don't know why there is no error message if there is effectively a mistake.
Here is the code and you will find as comment, the value of some variables.
CLEAR phrtext.
CLEAR estph_wa.
CLEAR estpp_wa.
CLEAR l_prop_val_wa.
REFRESH lt_estpp.
rt_estpp = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'VC_POSSIBLE_HASARDS' ).
ASSIGN rt_estpp->* TO <ts_estpp_ref>.
LOOP AT <ts_estpp_ref> ASSIGNING <ls_estpp_ref>.
ls_estpp_1 = <ls_estpp_ref>.
WRITE ls_estpp_1-phrtext+3 TO ls_estpp-phrtext+0.
ls_estpp-recnroot = ls_estpp_1-recnroot.
APPEND ls_estpp TO lt_estpp.
CLEAR ls_estpp.
CLEAR <ls_estpp_ref>.
ENDLOOP.
node_estpp = general_node->get_child_node( name = `POSSIBLE_HAZARDS` ).
node_estpp->bind_table( lt_estpp ).
DESCRIBE TABLE lt_estpp LINES sy-tfill.
IF sy-tfill > 0. " a revoir
tcg66_atnam = 'SAP_EHS_1011_001_ADVICE'.
CLEAR l_prop_header_wa.
header_primkey = header_primkey + 1.
l_prop_header_wa-primarykey = header_primkey. "int. key
l_prop_header_wa-flgprimkey = abap_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_1011_001'. " POSSIBLE_HAZARDS
APPEND l_prop_header_wa TO l_prop_header_tab.
LOOP AT lt_estpp INTO ls_estpp.
SELECT * FROM estpp INTO estpp_wa
WHERE langu = sy-langu
AND phrtext = ls_estpp-phrtext.
SELECT * FROM estph INTO estph_wa
WHERE recn = estpp_wa-recnroot.
SELECT SINGLE recntps FROM tcg66
INTO tcg66_recntps
WHERE atnam = tcg66_atnam.
IF sy-subrc = 0.
SELECT SINGLE recntph FROM estpj
INTO estpj_recntph
WHERE recntph = estph_wa-recn
AND recntps = tcg66_recntps.
IF sy-subrc = 0.
CLEAR l_prop_data_wa.
CLEAR l_prop_val_wa.
CONCATENATE estph_wa-catpin '-' estph_wa-phrid INTO l_prop_data_wa-char_value.
* Here is an example of the value of : l_prop_data_wa-char_value = 'ZACT-S066.0000136'
* when l_prop_data_wa-name_char = 'SAP_EHS_1011_001_ADVICE'
* prepare the VALUE tab
val_primkey = val_primkey + 1.
l_prop_val_wa-primarykey = val_primkey.
l_prop_val_wa-flgprimkey = abap_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.
data_primkey = data_primkey + 1.
l_prop_data_wa-primarykey = data_primkey.
l_prop_data_wa-flgprimkey = abap_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-name_char = 'SAP_EHS_1011_001_ADVICE'.
l_prop_data_wa-oper_inc = 0.
APPEND l_prop_data_wa TO l_prop_data_tab.
CLEAR l_prop_data_wa.
data_primkey = data_primkey + 1.
l_prop_data_wa-primarykey = data_primkey.
l_prop_data_wa-flgprimkey = abap_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-name_char = 'SAP_EHS_1011_001_CHRONIC'.
l_prop_data_wa-oper_inc = 0.
l_prop_data_wa-char_value = 'ZACT-E04.00590010'.
APPEND l_prop_data_wa TO l_prop_data_tab.
CLEAR l_prop_data_wa.
data_primkey = data_primkey + 1.
l_prop_data_wa-primarykey = data_primkey.
l_prop_data_wa-flgprimkey = abap_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-name_char = 'SAP_EHS_1011_001_MEDICAL'.
l_prop_data_wa-oper_inc = 0.
l_prop_data_wa-char_value = 'ZACT-N11.00220320'.
APPEND l_prop_data_wa TO l_prop_data_tab.
CLEAR l_prop_data_wa.
data_primkey = data_primkey + 1.
l_prop_data_wa-primarykey = data_primkey.
l_prop_data_wa-flgprimkey = abap_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-name_char = 'SAP_EHS_1011_001_ENTRY'.
l_prop_data_wa-oper_inc = 0.
l_prop_data_wa-char_value = 'ZACT-H04.00000070'.
APPEND l_prop_data_wa TO l_prop_data_tab.
CLEAR l_prop_data_wa.
data_primkey = data_primkey + 1.
l_prop_data_wa-primarykey = data_primkey.
l_prop_data_wa-flgprimkey = abap_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-name_char = 'SAP_EHS_1011_001_ORGANS'.
l_prop_data_wa-oper_inc = 0.
l_prop_data_wa-char_value = 'ZACT-N11.00018830'.
APPEND l_prop_data_wa TO l_prop_data_tab.
* * prepare the VALUE ASSIGNMENT ASSESSMENT tab
CLEAR l_prop_assess_wa.
data_primkey = data_primkey + 1.
l_prop_assess_wa-primarykey = data_primkey.
l_prop_assess_wa-flgprimkey = abap_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.
ENDIF. ENDIF. ENDSELECT. ENDSELECT ENDLOOP. ENDIF.
Hopefully that will be helpfull and thanks in advance for your help.
May i ask you if you can post links of threads in any FORUM , showing example of valide source code.
Hello
as explained in thread:
there are a number of OSS notes available. OSS notes are not always corrections of code but sometimes they gives recommendattions etc. To get acces to these notes you need only the so called "S User" which you can get easily. One of the OSS notes mentioned there (in the thread) contains I belive three or four SAP reports giving examples how to use the BAPIS correct.
This special OSS note is
a.) a consulting note
b.) and at these same time you can get some transports with the reports
Give them a try. They should help you to understand how to use the BAPIs.
C.B.
User | Count |
---|---|
13 | |
6 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.