Friday, October 12, 2012
The type or namespace name 'RfcConfigParameters' could not be found (are you missing ...
SAP .NET Connector 3.0 (NCo 3.0) is very useful for developing third party .NET based programs to extend the use of processes. And it is very well explained in its standard bundled documentation unlike the old versions. After you add references , you can easily start using provided framework, SAP.Middleware.Connector . Here I won't tell you about this framework however If you have errors like "The type or namespace name 'RfcConfigParameters' could not be found (are you missing ..." instead of a successful addition , don't forget to check your projects target framework, Project Properties -> Application -> Target Framework . It have to be .NET FrameWork 4 .
Friday, September 21, 2012
Scan Source Code
If you need to find out where a particular string is used in a source code,
go to SE38 and run RS_ABAP_SOURCE_SCAN
or check ewk1 transaction code.
Thursday, September 6, 2012
Split File And Path
Here is the simple solution for a problem that we frequently faced, splitting path and file name from files full path.
DATA : lv_file_path TYPE string VALUE 'C:\inetpub\wwwroot\welcome.png'.
DATA : lv_path_only type string ,
lv_filename_only type string.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = lv_file_path
IMPORTING
stripped_name = lv_path_only
file_path = lv_filename_only
EXCEPTIONS
x_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
RESULT :
LV_PATH_ONLY >> 'welcome.png'
LV_FILENAME_ONLY >> 'C:\inetpub\wwwroot\'
BAPI_PRODORDCONF_CREATE_TT Activity Confirmation
DATA :
lt_timeticket TYPE TABLE OF bapi_pp_timeticket,
lt_goodsmovements TYPE TABLE OF bapi2017_gm_item_create,
lt_link_conf_goods_mov TYPE TABLE OF bapi_link_conf_goodsmov,
lt_detail_return TYPE TABLE OF bapi_coru_return WITH HEADER LINE.
DATA :
ls_timeticket TYPE bapi_pp_timeticket,
ls_goodsmovements TYPE bapi2017_gm_item_create,
ls_link_conf_goods_mov TYPE bapi_link_conf_goodsmov,
ls_bapi_propose TYPE bapi_pp_conf_prop,
ls_bapi_return TYPE bapiret1,
ls_detail_return TYPE bapi_coru_return.
ls_timeticket-orderid = i_aufnr. " Order
ls_timeticket-operation = i_vornr. " Order Item
* ls_timeticket-fin_conf = 'X'. " Finish Confirmation
* ls_timeticket-clear_res = 'X'.
ls_timeticket-postg_date = sy-datum.
* ls_timeticket-yield = ''.
ls_timeticket-conf_acti_unit1 =
ls_timeticket-conf_acti_unit1_iso = ''. " First UOM
ls_timeticket-conf_activity1 = ''. " First Quantity
ls_timeticket-conf_acti_unit2 =
ls_timeticket-conf_acti_unit2_iso = ''. " Second UOM
ls_timeticket-conf_activity2 = ''. " Second Quantity
APPEND ls_timeticket TO lt_timeticket.
LOOP AT et_list WHERE erfmg > 0.
CLEAR ls_goodsmovements.
ls_goodsmovements-material = et_list-matnr.
ls_goodsmovements-plant = i_plant.
ls_goodsmovements-stge_loc = et_list-lgort.
ls_goodsmovements-batch = et_list-charg.
ls_goodsmovements-move_type = '261'.
ls_goodsmovements-stck_type = ''.
ls_goodsmovements-spec_stock = ''.
ls_goodsmovements-entry_qnt = et_list-erfmg.
ls_goodsmovements-entry_uom = et_list-erfme.
APPEND ls_goodsmovements TO lt_goodsmovements.
CLEAR ls_link_conf_goods_mov.
ls_link_conf_goods_mov-index_confirm = 1.
ls_link_conf_goods_mov-index_goodsmov = sy-tabix.
APPEND ls_link_conf_goods_mov TO lt_link_conf_goods_mov.
ENDLOOP.
*** BAPI
CALL FUNCTION 'BAPI_PRODORDCONF_CREATE_TT'
IMPORTING
return = ls_bapi_return
TABLES
timetickets = lt_timeticket
goodsmovements = lt_goodsmovements
link_conf_goodsmov = lt_link_conf_goods_mov
detail_return = lt_detail_return.
IF ls_bapi_return IS INITIAL.
*** Commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
*** Get Confirmation Number
LOOP AT lt_detail_return WHERE type = 'I'
AND id = 'RU'
AND number = '100'.
ENDLOOP.
IF sy-subrc NE 0.
LOOP AT lt_detail_return.
ENDLOOP.
ENDIF.
*** Check COGI
DATA : lt_affw TYPE TABLE OF affw WITH HEADER LINE.
DATA : lv_mes_text TYPE string.
SELECT * FROM affw INTO TABLE lt_affw
WHERE aufnr = i_aufnr
AND rueck = lt_detail_return-conf_no
AND rmzhl = lt_detail_return-conf_cnt.
IF sy-subrc EQ 0.
CONCATENATE gv_temp_message '-' '------- COGI warning message'
INTO gv_temp_message SEPARATED BY ' '.
ENDIF.
LOOP AT lt_affw.
PERFORM get_text_from_message USING lt_affw-msgid
lt_affw-msgno
lt_affw-msgv1
lt_affw-msgv2
lt_affw-msgv3
lt_affw-msgv4
CHANGING lv_mes_text.
ENDLOOP.
*** Set Message OK
ELSE.
LOOP AT lt_detail_return.
ENDLOOP.
*** Set Message ERROR
ENDIF.
Thursday, May 24, 2012
Get Current Function Name
Dynamic programming is essential for keeping code clean, tidy and reusable. For this purpose we always need to get information about objects, types, elements (whatever) at runtime. For example, you have to log some kind of event and you need to include the report name which triggered the related event. Basically ABAP developers check sy fields in the first place. In this situation we can get the solution by using sy-repid however when you need the current function name at runtime that variable gives the function group program name which won't work for us. For finding function name at runtime, you can use the code below.
DATA : lt_callstack TYPE sys_callst ,
ls_callstack LIKE LINE OF lt_callstack.
*** Get Stack
CALL FUNCTION 'SYSTEM_CALLSTACK'
EXPORTING
max_level = 0
IMPORTING
et_callstack = lt_callstack.
LOOP AT lt_callstack INTO ls_callstack
WHERE eventtype = 'FUNC'. " Get Last FUNC Call
EXIT.
ENDLOOP.
*** Set Function Name
e_function_name = ls_callstack-eventname.
Thursday, May 17, 2012
Get Payslip PDF
*** Data
DATA : gv_seqnr LIKE pa0001-seqnr,
gv_pernr LIKE pa0001-pernr.
DATA : gt_form LIKE pc408 OCCURS 0 WITH HEADER LINE,
gs_info LIKE pc407 ,
gs_return TYPE bapireturn1.
*** Function
CALL FUNCTION 'GET_PAYSLIP'
EXPORTING
employee_number = gv_pernr
sequence_number = gv_seqnr
payslip_variant = 'PDF'
IMPORTING
return = gs_return
p_info = gs_info
TABLES
p_form = gt_form[].
Wednesday, May 16, 2012
Reverse Goods Issue
This code snippet shows you how to reverse goods issue.It is pretty simple.
DATA : lv_vbtyp TYPE likp-vbtyp,
lv_vbeln TYPE vbuk-vbeln.
DATA : lt_mesg TYPE TABLE OF mesg ,
ls_mesg LIKE LINE OF lt_mesg.
lv_vbeln = '10000012'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_vbeln
IMPORTING
output = lv_vbeln.
SELECT SINGLE vbtyp FROM likp
INTO lv_vbtyp
WHERE vbeln = lv_vbeln. " Check Document
CHECK sy-subrc EQ 0. " Check Document
SELECT SINGLE COUNT(*) FROM vbuk
WHERE vbeln = lv_vbeln
AND wbstk = 'C'.
CHECK sy-subrc EQ 0. " Check Status.
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
i_vbeln = lv_vbeln
i_budat = sy-datum
i_vbtyp = lv_vbtyp
i_tcode = 'VL09'
TABLES
t_mesg = lt_mesg
EXCEPTIONS
error_reverse_goods_issue = 1
OTHERS = 2.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
LOOP AT lt_mesg INTO ls_mesg. " Get Messages
ENDLOOP.
ENDIF.
DATA : lv_vbtyp TYPE likp-vbtyp,
lv_vbeln TYPE vbuk-vbeln.
DATA : lt_mesg TYPE TABLE OF mesg ,
ls_mesg LIKE LINE OF lt_mesg.
lv_vbeln = '10000012'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_vbeln
IMPORTING
output = lv_vbeln.
SELECT SINGLE vbtyp FROM likp
INTO lv_vbtyp
WHERE vbeln = lv_vbeln. " Check Document
CHECK sy-subrc EQ 0. " Check Document
SELECT SINGLE COUNT(*) FROM vbuk
WHERE vbeln = lv_vbeln
AND wbstk = 'C'.
CHECK sy-subrc EQ 0. " Check Status.
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
i_vbeln = lv_vbeln
i_budat = sy-datum
i_vbtyp = lv_vbtyp
i_tcode = 'VL09'
TABLES
t_mesg = lt_mesg
EXCEPTIONS
error_reverse_goods_issue = 1
OTHERS = 2.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
LOOP AT lt_mesg INTO ls_mesg. " Get Messages
ENDLOOP.
ENDIF.
Wednesday, April 25, 2012
HU_CREATE_GOODS_MOVEMENT
HU_CREATE_GOODS_MOVEMENT example ;
DATA : lv_posted TYPE sysubrc,
ls_mess TYPE huitem_messages ,
lt_mess TYPE huitem_messages_t WITH HEADER LINE,
ls_emkpf TYPE emkpf ,
lt_move_to TYPE hum_data_move_to_t,
lt_exidv TYPE hum_exidv_t WITH HEADER LINE,
ls_move_to TYPE hum_data_move_to,
ls_hu_items TYPE hum_humseg,
lv_venum TYPE vekp-venum,
gv_temp_message TYPE string.
DATA : lt_vepo TYPE TABLE OF vepo WITH HEADER LINE.
lv_venum = '100000012'. " Internal HU Number
SELECT * FROM vepo INTO TABLE lt_vepo
WHERE venum = lv_venum.
IF sy-subrc NE 0.
MESSAGE 'Please enter a valid HU !' TYPE 'I'.
EXIT.
ENDIF.
LOOP AT lt_vepo.
*** Move
ls_move_to-huwbevent = '0010'. " Process Indicator
ls_move_to-matnr = '01010101'. " Material Number
ls_move_to-lgort = lt_vepo-lgort. "
ls_move_to-grund = '0004'. " Fixed Reason
ls_move_to-bwart = '309'. " Movement Type
ls_hu_items-venum = lt_vepo-venum.
ls_hu_items-vepos = lt_vepo-vepos.
APPEND ls_hu_items TO ls_move_to-hu_items.
APPEND ls_move_to TO lt_move_to.
ENDLOOP.
*** Refresh
CALL FUNCTION 'HU_PACKING_REFRESH'.
PERFORM refresh_change_stock(saplv51e).
*** Call Function
CALL FUNCTION 'HU_CREATE_GOODS_MOVEMENT'
EXPORTING
* if_event = lv_event
if_simulate = ' '
if_commit = ' '
* if_tcode = 'MOBIL'
it_move_to = lt_move_to[]
it_external_id = lt_exidv[]
IMPORTING
ef_posted = lv_posted
es_message = ls_mess
et_messages = lt_mess[]
es_emkpf = ls_emkpf.
*** Check Result
IF NOT lv_posted = 1.
ROLLBACK WORK.
CALL FUNCTION 'HU_PACKING_REFRESH'.
CALL FUNCTION 'SERIAL_INTTAB_REFRESH'.
MESSAGE 'Problem occured!' TYPE 'I'.
ELSE.
COMMIT WORK AND WAIT.
CONCATENATE ls_emkpf-mblnr
ls_emkpf-mjahr
' document created!'
INTO gv_temp_message SEPARATED BY ' '.
MESSAGE gv_temp_message TYPE 'I'.
ENDIF.
DATA : lv_posted TYPE sysubrc,
ls_mess TYPE huitem_messages ,
lt_mess TYPE huitem_messages_t WITH HEADER LINE,
ls_emkpf TYPE emkpf ,
lt_move_to TYPE hum_data_move_to_t,
lt_exidv TYPE hum_exidv_t WITH HEADER LINE,
ls_move_to TYPE hum_data_move_to,
ls_hu_items TYPE hum_humseg,
lv_venum TYPE vekp-venum,
gv_temp_message TYPE string.
DATA : lt_vepo TYPE TABLE OF vepo WITH HEADER LINE.
lv_venum = '100000012'. " Internal HU Number
SELECT * FROM vepo INTO TABLE lt_vepo
WHERE venum = lv_venum.
IF sy-subrc NE 0.
MESSAGE 'Please enter a valid HU !' TYPE 'I'.
EXIT.
ENDIF.
LOOP AT lt_vepo.
*** Move
ls_move_to-huwbevent = '0010'. " Process Indicator
ls_move_to-matnr = '01010101'. " Material Number
ls_move_to-lgort = lt_vepo-lgort. "
ls_move_to-grund = '0004'. " Fixed Reason
ls_move_to-bwart = '309'. " Movement Type
ls_hu_items-venum = lt_vepo-venum.
ls_hu_items-vepos = lt_vepo-vepos.
APPEND ls_hu_items TO ls_move_to-hu_items.
APPEND ls_move_to TO lt_move_to.
ENDLOOP.
*** Refresh
CALL FUNCTION 'HU_PACKING_REFRESH'.
PERFORM refresh_change_stock(saplv51e).
*** Call Function
CALL FUNCTION 'HU_CREATE_GOODS_MOVEMENT'
EXPORTING
* if_event = lv_event
if_simulate = ' '
if_commit = ' '
* if_tcode = 'MOBIL'
it_move_to = lt_move_to[]
it_external_id = lt_exidv[]
IMPORTING
ef_posted = lv_posted
es_message = ls_mess
et_messages = lt_mess[]
es_emkpf = ls_emkpf.
*** Check Result
IF NOT lv_posted = 1.
ROLLBACK WORK.
CALL FUNCTION 'HU_PACKING_REFRESH'.
CALL FUNCTION 'SERIAL_INTTAB_REFRESH'.
MESSAGE 'Problem occured!' TYPE 'I'.
ELSE.
COMMIT WORK AND WAIT.
CONCATENATE ls_emkpf-mblnr
ls_emkpf-mjahr
' document created!'
INTO gv_temp_message SEPARATED BY ' '.
MESSAGE gv_temp_message TYPE 'I'.
ENDIF.
Get Handling Unit Items From Delivery
By the help of the code snippet below , you can get handling units related with specified delivery.
LT_HUS -> Handling Unit Headers -> VEKP
LT_HUPOS-> Handling Unit Items -> VEPO
DATA : i_delivery TYPE likp-vbeln.
DATA : is_object TYPE hum_object.
DATA : lt_hus TYPE hum_hu_header_t WITH HEADER LINE,
lt_hupos TYPE hum_hu_item_t WITH HEADER LINE,
lt_serialno TYPE vsep_t_rserob.
is_object-object = '03'.
is_object-objkey = i_delivery.
CALL FUNCTION 'HU_GET_HUS'
EXPORTING
if_lock_hus = 'X'
if_with_text = ' '
is_objects = is_object
IMPORTING
et_header = lt_hus[]
et_items = lt_hupos[]
et_item_serialno = lt_serialno
EXCEPTIONS
hus_locked = 1
no_hu_found = 2
fatal_error = 3
OTHERS = 4.
LT_HUS -> Handling Unit Headers -> VEKP
LT_HUPOS-> Handling Unit Items -> VEPO
DATA : i_delivery TYPE likp-vbeln.
DATA : is_object TYPE hum_object.
DATA : lt_hus TYPE hum_hu_header_t WITH HEADER LINE,
lt_hupos TYPE hum_hu_item_t WITH HEADER LINE,
lt_serialno TYPE vsep_t_rserob.
is_object-object = '03'.
is_object-objkey = i_delivery.
CALL FUNCTION 'HU_GET_HUS'
EXPORTING
if_lock_hus = 'X'
if_with_text = ' '
is_objects = is_object
IMPORTING
et_header = lt_hus[]
et_items = lt_hupos[]
et_item_serialno = lt_serialno
EXCEPTIONS
hus_locked = 1
no_hu_found = 2
fatal_error = 3
OTHERS = 4.
Wednesday, March 28, 2012
Change SAP Web Service Default Login Language
We can configure web services using SOAMANAGER transaction for a long time. This application controls icf nodes regarding selected web services which makes the WS publishing process easier for us. Unfortunately last version of SOAMANAGER don't have an option to change WS login language , either SICF does not allow us to change directly related node and gives SHTTP824 error.
I have tried a little bit to find a solution however nothing came out. So I decided to code for myself and put it into my toolbox. The program below lets you change WS default login language. After execution it opens sicf transaction by selecting the node you entered. Deactivate and activate node. It's done.
I have tried a little bit to find a solution however nothing came out. So I decided to code for myself and put it into my toolbox. The program below lets you change WS default login language. After execution it opens sicf transaction by selecting the node you entered. Deactivate and activate node. It's done.
*&---------------------------------------------------------------------*
*& Report ZBCP_CHANGE_WS_LANGU
*&---------------------------------------------------------------------*
REPORT zbcp_change_ws_langu.
TABLES : icfservice.
DATA : gt_nodes TYPE TABLE OF icfservice.
PARAMETERS : p_lng_fr TYPE sy-langu OBLIGATORY DEFAULT 'EN'.
PARAMETERS : p_lng_to TYPE sy-langu OBLIGATORY DEFAULT sy-langu.
PARAMETERS : p_node TYPE icfservice-icf_name OBLIGATORY.
START-OF-SELECTION.
SELECT * FROM icfservice INTO TABLE gt_nodes
WHERE icf_name = p_node
AND icf_langu = p_lng_fr.
IF sy-subrc NE 0.
MESSAGE 'Node does not exists!' TYPE 'I'.
EXIT.
ENDIF.
LOOP AT gt_nodes INTO icfservice.
icfservice-icf_langu = p_lng_to.
MODIFY icfservice.
ENDLOOP.
MESSAGE 'It''s done please reactivate node !'
TYPE 'S'.
SUBMIT rsicftree WITH icf_serv = p_node AND RETURN.
Thursday, February 2, 2012
SITIST 2011 - My Presentation
For the 2nd time Sap Inside Track Event was organized by the help of SAP Turkey and SDN community members in İstanbul. I couldn't participated first SIT İstanbul event. However I went to Ankara to be together with the community members. That was really fun. After SIT Ankara event I decided to host a session instead of being just a participant. So, on December 3rd 2011, I had a session to support this event. I think SIT events are so important for Turkish SAP community to get together and share experiences.
Blogs about the event ;
Dilek Adak
Abdülbasit Gülşen
Hüseyin Bilgen
And you can display my PRESENTATION in here.
Sitist 2011 hdereli REST With ABAP and SAP NetWeaver Gateway
* Some of the images that I've used in presentation are not mine.
Friday, January 27, 2012
ABAP Dynamic Function Call
Code sample below shows how to implement a dynamic function call. Actually we need that kind of dynamic function call rarely instead of static call. However it helped me a lot in a complicated scenario. Less code , less effort and a clean code...
Also you can check standard documentation in here .
Also you can check standard documentation in here .
Tuesday, November 15, 2011
Open New Window Using ABAP
While displaying a report , generally user wants to drill down by clicking one of the lines or cells to get more detailed information about related topic. Most common behavior to accomplish this task is displaying detailed information at the same window. However in some cases users need to display the detailed report in another window. They need to see both reports inside different windows. For this purpose check sample below.
DATA : ls_params TYPE tpara,
lt_params TYPE TABLE OF tpara.
ls_params-paramid = 'BUK'.
ls_params-partext = '0001'.
APPEND ls_params TO lt_params.
ls_params-paramid = 'BLN'.
ls_params-partext = '00000101'.
APPEND ls_params TO lt_params.
ls_params-paramid = 'GJR'.
ls_params-partext = '2011'.
APPEND ls_params TO lt_params.
CALL FUNCTION 'CC_CALL_TRANSACTION_NEW_TASK'
STARTING NEW TASK 'FB03_TASK'
DESTINATION 'NONE'
EXPORTING
transaction = 'FB03'
skip_first_screen = 'X'
TABLES
paramtab = lt_params
EXCEPTIONS
communication_failure = 97
system_failure = 98
OTHERS = 99.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
lt_params TYPE TABLE OF tpara.
ls_params-paramid = 'BUK'.
ls_params-partext = '0001'.
APPEND ls_params TO lt_params.
ls_params-paramid = 'BLN'.
ls_params-partext = '00000101'.
APPEND ls_params TO lt_params.
ls_params-paramid = 'GJR'.
ls_params-partext = '2011'.
APPEND ls_params TO lt_params.
CALL FUNCTION 'CC_CALL_TRANSACTION_NEW_TASK'
STARTING NEW TASK 'FB03_TASK'
DESTINATION 'NONE'
EXPORTING
transaction = 'FB03'
skip_first_screen = 'X'
TABLES
paramtab = lt_params
EXCEPTIONS
communication_failure = 97
system_failure = 98
OTHERS = 99.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Subscribe to:
Posts (Atom)