2011 Jun 17 10:01 AM
TABLES: vbap.
SELECT-OPTIONS: s_vbeln for vbap-vbeln,
s_matnr for vbap-matnr.
TYPES :BEGIN OF y_vbap,
vbeln TYPE vbeln_va,
matnr TYPE matnr,
end of y_vbap.
DATA : it_vbap TYPE STANDARD TABLE OF y_vbap,
wa_vbap TYPE y_vbap.
START-OF-SELECTION.
SELECT vbeln
matnr
into TABLE it_vbap
FROM vbap
WHERE vbeln in s_vbeln.
loop at it_vbap INTO wa_vbap.
WRITE:/5 wa_vbap-vbeln, 20 wa_vbap-matnr.
endloop.
at LINE-SELECTION.
if s_vbeln = wa_vbap-vbeln.
set PARAMETER ID 'DFD' FIELD s_vbeln.
call TRANSACTION 'VA01' and skip first screen.
else.
s_matnr = wa_vbap-matnr.
set PARAMETER ID 'MAT' FIELD s_matnr.
call TRANSACTION 'MM01' and skip first screen.
ENDIF.
hi friends. my problem is here i am getting 2 transaction codes same like VA01. but i need when i cliked vbeln i want
Create sales Oder screen and when i cliked matnr i want Create meterial. plz tell me what is the wrong in this code.
Moderator message: please choose more descriptive subject lines for your posts.
Edited by: Thomas Zloch on Jun 17, 2011 11:22 AM
TABLES: vbap.
SELECT-OPTIONS: s_vbeln for vbap-vbeln,
s_matnr for vbap-matnr.
TYPES :BEGIN OF y_vbap,
vbeln TYPE vbeln_va,
matnr TYPE matnr,
end of y_vbap.
DATA : it_vbap TYPE STANDARD TABLE OF y_vbap,
wa_vbap TYPE y_vbap.
START-OF-SELECTION.
SELECT vbeln
matnr
into TABLE it_vbap
FROM vbap
WHERE vbeln in s_vbeln.
loop at it_vbap INTO wa_vbap.
WRITE:/5 wa_vbap-vbeln, 20 wa_vbap-matnr.
endloop.
at LINE-SELECTION.
if s_vbeln = wa_vbap-vbeln.
set PARAMETER ID 'DFD' FIELD s_vbeln.
call TRANSACTION 'VA01' and skip first screen.
else.
s_matnr = wa_vbap-matnr.
set PARAMETER ID 'MAT' FIELD s_matnr.
call TRANSACTION 'MM01' and skip first screen.
ENDIF.
hi friends. my problem is here i am getting 2 transaction codes same like VA01. but i need when i cliked vbeln i want
Create sales Oder screen and when i cliked matnr i want Create meterial. plz tell me what is the wrong in this code.
Moderator message: please choose more descriptive subject lines for your posts.
Edited by: Thomas Zloch on Jun 17, 2011 11:22 AM
2011 Jun 17 10:05 AM
Hi,
1) You need to give a better subject to your query.
2) You are using at line selection... IS this an interactive report? If yes, then you need to use HIDE statement.Other wise at line selection doesnt make sense.
in current scenario you at line selection would have teh last record from loop into the workarea.
You are comparing a single value from WA to a select -options... select-option is a table!! please chnage that.
what is your exact requirment.
Edited by: sap_wiz on Jun 17, 2011 2:37 PM
2011 Jun 17 10:09 AM
S_vbeln is a select-option and can contain multiple values, in addition, it is like a stracture. but wa_vbap-vbeln is a field. type mismatch and hecn the condition fails.
please check and correct your code.
2011 Jun 17 10:21 AM
Hi,
Your checking only vbeln values only. Your not checking Plant
SELECT vbeln
matnr
into TABLE it_vbap
FROM vbap
WHERE vbeln in s_vbeln."checking only Sales order number
use the code for line selection.
at LINE-SELECTION.
DATA : val(20),
lv_val1 (10),"for vbeln
lv_val2(18)," for matnr
GET CURSOR VALUE val."get the cursor position value
IF val is NOT INITIAL.
CONDENSE val."delete the space
SELECT SINGLE vbeln INTO lv_val1 FROM vbap WHERE vbeln = val.
SELECT SINGLE matnr INTO lv_val2 FROM mara WHERE matnr = val.
ENDIF.
if lv_val1 is not initial."vbeln select
set PARAMETER ID 'DFD' FIELD lv_val1.
call TRANSACTION 'VA01' and skip first screen.
elseif lv_val2 is not initial. "matnr select
set PARAMETER ID 'MAT' FIELD lv_val2.
call TRANSACTION 'MM01' and skip first screen.
ENDIF.
Regards,
Dhina..
Edited by: Dhina DMD on Jun 17, 2011 11:23 AM
Edited by: Dhina DMD on Jun 17, 2011 11:31 AM
2011 Jun 17 10:21 AM
Hi,
Use this below code.
I had done some changes to your code.
I think this will helpful to you.
You have you improve your techinical skills in writing the coded.
TABLES: VBAP.
SELECT-OPTIONS: S_VBELN FOR VBAP-VBELN,
S_MATNR FOR VBAP-MATNR.
TYPES :BEGIN OF Y_VBAP,
VBELN TYPE VBELN_VA,
MATNR TYPE MATNR,
END OF Y_VBAP.
DATA : IT_VBAP TYPE STANDARD TABLE OF Y_VBAP,
WA_VBAP TYPE Y_VBAP.
*If not input
IF S_VBELN[] IS INITIAL AND
S_MATNR[] IS INITIAL.
WRITE:/ 'ENTER EITHER VENDOR or MATERIAL' COLOR COL_NEGATIVE.
RETURN.
ENDIF.
*If both are selected
IF S_VBELN[] IS NOT INITIAL AND
S_MATNR[] IS NOT INITIAL.
WRITE:/ 'MAINTAIN ONLY ONE EITHER VENDOR or MATERIAL' COLOR COL_NEGATIVE.
RETURN.
ENDIF.
START-OF-SELECTION.
SELECT VBELN
MATNR
INTO TABLE IT_VBAP
FROM VBAP
WHERE VBELN IN S_VBELN
AND MATNR IN S_MATNR.
IF SY-SUBRC NE 0.
WRITE:/ 'NO DATA FOR YOUR SELECTION' COLOR COL_NEGATIVE.
RETURN.
ENDIF.
IF S_VBELN[] IS NOT INITIAL.
LOOP AT IT_VBAP INTO WA_VBAP.
WRITE:/5 WA_VBAP-VBELN, 20 WA_VBAP-MATNR.
*endloop.
*at LINE-SELECTION.
*if s_vbeln = wa_vbap-vbeln.
SET PARAMETER ID 'DFD' FIELD WA_VBAP-VBELN. "s_vbeln.
CALL TRANSACTION 'VA01' AND SKIP FIRST SCREEN.
*else.
*s_matnr = wa_vbap-matnr.
*set PARAMETER ID 'MAT' FIELD s_matnr.
*call TRANSACTION 'MM01' and skip first screen.
ENDIF.
ENDLOOP.
ELSEIF S_MATNR[] IS NOT INITIAL.
LOOP AT IT_VBAP INTO WA_VBAP.
WRITE:/5 WA_VBAP-VBELN, 20 WA_VBAP-MATNR.
SET PARAMETER ID 'MAT' FIELD WA_VBAP-MATNR. "S_MATNR.
CALL TRANSACTION 'MM01' AND SKIP FIRST SCREEN.
ENDLOOP.
ENDIF.
Thanks & Regards,
Kruthik
2011 Jun 17 10:47 AM
Sorry, i havent seen the question correctly.
Please note your code is by line .. not by the value.
as the others suggested, Hotspot is the one which i know and will work.
the other one i do have to check.
update once your requirement gets the solution.
2011 Jun 17 10:23 AM
hi ,
add this
loop at it_vbap INTO wa_vbap.
WRITE:/5 wa_vbap-vbeln hotspot on COLOR 5 , 20 wa_vbap-matnr hotspot on COLOR 5.
endloop.
at line selection .
Then you will get that value on cursor field .
regards
Deepak.