2016 Mar 26 4:53 AM
Hello Experts,
I am using BAPI 'BAPI_PR_CREATE' to create PR in an Report . I am using bapi in an LOOP with below as such entries.
where Internal table LT_ITEM1 is referered to standard structure BAPIMEREQITEMIMP as below code.
IF LT_ITEM1[] IS NOT INITIAL .
CALL FUNCTION 'BAPI_PR_CREATE'
EXPORTING
PRHEADER = WA_HEADER2
PRHEADERX = WA_HEADERX2
* TESTRUN =
IMPORTING
NUMBER = WA_NUM2
* PRHEADEREXP =
TABLES
RETURN = T_RETURN2
PRITEM = LT_ITEM1
PRITEMX = LT_ITEMX1.
READ TABLE T_RETURN2 INTO WA_RETURN2 WITH KEY TYPE = 'S'.
IF SY-SUBRC = 0 .
CONCATENATE 'PR CREATED: ' WA_NUM2 INTO LV_OP2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
DELETE LT_FINAL WHERE SEL = 'X'.
MESSAGE LV_OP2 TYPE 'I'.
ELSE.
CONCATENATE 'Unable To Create PR' LV_MATNR2 INTO LV_MSG2.
MESSAGE LV_MSG2 TYPE 'I'.
ENDIF.
ENDIF.
Now the change is I need to create ONE PR for every change in fixed vendor, I mean ONE PR should be created for all cumilated Vendor line items
and entries which doesn't have vendor value One more PR should be created with no vendor.
My Problem is that I am not able to use AT New control break-statment ( as I thought for every change in fixed_vend field would fix my problem)
but I am not able to use the FIXED_VEND field is some where in 20th column from LEFT as it is standard structure, I am not able to chnage structure (I have brought to second column while debug just to make understand), any Key word suggested for such situation.
or I need to go with custom logic.
Help required.
Thanks in Advance.
2016 Mar 27 9:56 AM
Hi Prakash,
Try with "On CHANGE of "FIXED_VEND" ", this is also one of the event if control break processing.
Hope this will solve your issue.
Thanks.
Gupta
Hi Prakash,
Try with "On CHANGE of "FIXED_VEND" ", this is also one of the event if control break processing.
Hope this will solve your issue.
Thanks.
Gupta
2016 Mar 26 6:34 AM
Hi,
I will create one internal table and get the "fix_vend" data in the first column. Because the structure BAPIMEREQITEMIMP don't have key field so the second column data may be the number of current line(1,2,3...n).
Use command AT in this table to get the number. Then read table LT_ITEM1 with INDEX and perform your logic.
Hope it could help you.
Wish you nice Easter 😉
Regards,
Thanh.
2016 Mar 27 4:04 AM
Hi Thanh,
Thanks for Reply,I Tried with this trick actually, it didnt work as both structures are not mutally convertible.
Regards
Prakash Rao
2016 Mar 30 8:54 AM
Hi Prakash,
When you create custom structure, try to use "MOVE-CORRESPONDING" to transfer data of one internal table to another internal table. In that case you don't need to worry about mutually convertibility of two table structures.
Thanks,
Hardik.
2016 Mar 27 9:56 AM
Hi Prakash,
Try with "On CHANGE of "FIXED_VEND" ", this is also one of the event if control break processing.
Hope this will solve your issue.
Thanks.
Gupta
2016 Mar 27 10:09 AM
I wouldn't use ON CHANGE OF as ABAP documentation says "deprecated statement because it's very prone to errors" (and that's true), Prakash should better adopt the KISS principle: simply define a variable to store the previous value, and create the PR only when the value is changing.
2016 Mar 29 12:13 AM
Hm, I always thought that ON CHANGE was KISSer than a variable... It's not as much prone to errors as it's just misunderstood. Oh man, they are taking away all the good stuff in ABAP...
2016 Mar 29 7:41 AM
I agree: break statements/controls like ON CHANGE, AT NEW and so on are prone to errors if used in the wrong way.
Exactly like any others statement or instruction.
I can be boring but...it's just a matter of design and attention.
That alert sounds like "do not use cars! If you are drunken, you crash!".
EDIT
Are even Field-symbols deprecated? You know, people could modify data in internal table without really wanting it...
2016 Mar 29 11:25 AM
ON CHANGE OF forbidden in ABAP objects anyway, no choice. People still programming in the procedural way? (joke)
2016 Mar 29 11:37 AM
Hi All,
I am using ABAP 740 SP12 & the GROUP BY addition is simply awesome! SAP recommends using it instead of the LOOP control events
BR,
Suhas
2016 Mar 29 1:45 PM
2016 Mar 29 1:51 PM
2016 Mar 29 3:25 PM
I seem to recall that ON CHANGE OF became obsolete before ABAP Objects was invented. Certainly since I started in 1997, I've never used it.
OTOH I'm currently working on a program written just four years ago, by a consultant from SAP, that's full of obsolete constructs.
2016 Mar 30 8:26 AM
Talking about depreciation, did you know Form and EndForm are depreciated (and are marked as obsolete in the help ?!!)
2016 Mar 30 8:35 AM
Yes, i know.. so i'm waiting SAP remove all of them from its code *giggle*
2016 Mar 30 6:31 PM
Richard - yeah, I noticed that (had a good laugh). This is the standard program delivered in 2015:
SAP should clean up their own house first if they are taking the "Objects or bust" movement seriously. To be honest, I think it's a losing battle and maybe not even the one worth fighting considering where this whole thing is going...
2016 Mar 29 6:42 PM
Never mind, for some reason I confused ON CHANGE with AT... events in the LOOP. We don't use ON CHANGE, but I suspect AT will be taken away by evil SAP too.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |