GOS TOOLBAR
la_obj TYPE borident.
PARAMETERS: p_kunnr TYPE kna1-kunnr.
*
*
START-OF-SELECTION.
*
* Set object Key
la_obj-objtype = 'KNA1'.
la_obj-objkey = p_kunnr.
*
* GOS toolbar
CREATE OBJECT lo_manager
EXPORTING
is_object = la_obj
ip_no_commit = space
EXCEPTIONS
OTHERS = 1.
*
* To generate output
WRITE: 'GOS test for Customer'.
Generic Object Services (GOS) Attach URL with multiple customer
TABLES : kna1.
SELECTION-SCREEN : BEGIN OF BLOCK sel WITH FRAME TITLE text-001.
SELECT-OPTIONS : p_key FOR kna1-kunnr.
SELECTION-SCREEN : END OF BLOCK sel.
DATA: BEGIN OF itab_wa,
kunnr LIKE kna1-kunnr,
END OF itab_wa.
DATA: itab LIKE itab_wa OCCURS 0 WITH HEADER LINE.
DATA :p_bo TYPE swotentry-objtype.
DATA :p_url TYPE soli .
p_url = 'www.sdn.sap.com'.
p_bo = 'KNA1'.
DATA: lv_object_a TYPE sibflporb,
lv_object_b TYPE sibflporb,
lv_reltyp TYPE mdoblrel-reltype,
lv_folder TYPE soodk,
lv_doc TYPE soodk,
lv_object TYPE sood1,
lv_file TYPE rlgrap-filename,
lv_name TYPE sood-objdes,
lv_type TYPE sood-file_ext,
lv_filename TYPE filep,
lv_fileextn TYPE dappl,
lv_length TYPE i,
lv_offset TYPE i,
lv_full_lines TYPE i,
lv_last_length TYPE i,
lv_tdname LIKE thead-tdname,
lt_tline TYPE TABLE OF tline,
wa_tline TYPE tline,
lt_links TYPE TABLE OF bapi_doc_drad_select,
wa_links TYPE bapi_doc_drad_select,
lv_dktxt TYPE dktxt,
lv_ltxin TYPE ltxin,
it_content TYPE STANDARD TABLE OF soli,
URL_content TYPE STANDARD TABLE OF soli,
wa_content TYPE soli.
DATA : lt_srgbtbrel TYPE srgbtbrel OCCURS 10.
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
region = 'B'
IMPORTING
folder_id = lv_folder
EXCEPTIONS
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
ENDIF.
lv_object-objla = 'EN'.
lv_object-objnam = 'MESSAGE'.
lv_object-objdes = 'test'.
break developer.
*CONCATENATE '&KEY&' p_url INTO wa_content-line.
APPEND wa_content TO it_content.
PERFORM populate_itab.
CALL FUNCTION 'SO_DOCUMENT_INSERT'
EXPORTING
parent_id = lv_folder
object_hd_change = lv_object
document_type = 'URL'
IMPORTING
document_id = lv_doc
TABLES
objcont_text = it_content
EXCEPTIONS
active_user_not_exist = 1
dl_name_exist = 2
folder_not_exist = 3
folder_no_authorization = 4
object_type_not_exist = 5
operation_no_authorization = 6
owner_not_exist = 7
parameter_error = 8
substitute_not_active = 9
substitute_not_defined = 10
x_error = 11
OTHERS = 12.
IF sy-subrc EQ 0.
LOOP AT itab.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_srgbtbrel
FROM srgbtbrel
WHERE instid_a = itab-kunnr
AND typeid_a = p_bo
AND reltype = 'URL'.
IF LINES( lt_srgbtbrel ) IS INITIAL.
MOVE: itab-kunnr TO lv_object_a-instid,
p_bo TO lv_object_a-typeid,
'BO' TO lv_object_a-catid.
CONCATENATE lv_folder-objtp lv_folder-objyr lv_folder-objno
lv_doc-objtp lv_doc-objyr lv_doc-objno
INTO lv_object_b-instid.
lv_object_b-typeid = 'MESSAGE'.
lv_object_b-catid = 'BO'.
TRY.
CALL METHOD cl_binary_relation=>create_link
EXPORTING
is_object_a = lv_object_a
is_object_b = lv_object_b
ip_reltype = 'URL'.
CATCH cx_obl_parameter_error .
CATCH cx_obl_model_error .
CATCH cx_obl_internal_error .
ENDTRY.
ELSE.
SKIP .
ENDIF.
ENDLOOP.
COMMIT WORK.
REFRESH : itab, it_content.
CLEAR : itab, it_content.
SET SCREEN 0.
ENDIF.
*&---------------------------------------------------------------------*
*& Form POPULATE_ITAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM populate_itab .
LOOP AT p_key .
IF p_key-sign = 'I'.
IF p_key-option = 'EQ'.
itab_wa-kunnr = p_key-low.
APPEND itab_wa TO itab.
ELSEIF p_key-option = 'BT'.
DO.
itab_wa-kunnr = p_key-low.
APPEND itab_wa TO itab.
IF p_key-low EQ p_key-high.
EXIT.
ELSE.
ENDIF.
ENDDO.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " POPULATE_ITAB
BADI_How to Find it_&implement it
Badi - Bussiness Addins.
Method used for enhancement for standard SAP code. It is advisible not to change existing SAP code which is known as Modification. SAP provides and alternative to this modification which is known as Enhancement. Herein SAP provides points where the user may add his code to be reflected while a standard transaction is run.
Badi uses the concept of object oriented programming. In most of the standard transactions, SAP has provided hooks to add own code via methods of classes.
How to search a Badi ?
1. Goto and enter CL_EXITHANDLER and click on display.
2. Double click on the method _INSTANCE. Set breakpoint on CL_=>GET_CLASS_NAME_ON_INTERFACE. This works for the classic BAdI. In case you want to find the positions where methods of the new BAdI are called, just set a breakpoint on CALL BADI in the programm or class where you search for BAdI calls.
3. Run the transaction for which you want to search the Badi's.
4. Now whenever the method is called, the program goes into debugging mode. Check the value of exit_name (changing parameter),this would give the name of the Badi's.
5. Run the entire transaction and note down all the Badi's.
Some other ways to find out BADI,
→ Buffer trace (ST05) as BADI database tables are buffered. Run transaction and observe the BADI found.

→ SPRO (SAP IMG Reference)

→ SE84 (Repository Information System) → BADI definitions → Package (Development Class) → BADI definition name

Implementing the Badi.
1. Go to to check the defination of the Badi and
2. to implement the Badi.
3. Enter the name of the Badi in the create implementaion section (if you are creating a new implementation - Radiobutton Classic Badi) and click on createImplementaion.
4. Enter the name of the implementation.
5. Double click on the method name and add the code for the implementation.
Following is a Practical scenario.
Use of transaction PA40 to terminate an employee. The requirement is that when we reach the screen where the personel sub area and position have to be filled they should be auto populated with the respective values. Personel sub area should be the same as it was when the employee was first hired and the position should be defaulted to 99999999.
Upon using the above procedure to find the Badi to be used, it was found that the Badi which will be used for this purpose would be "HRPAD00INFTY". The method to be used is BEFORE_.
Upon further investigation it is found that the method is being called twice in the same transaction, so we will have to restrict the Badi to run only on the screen required else it will throw a dump.The screen numberon which we need the Badi to be executed is 2010.Upon check the parameters of the method the available structures are all importing so no value can be assigned to change the value of the screen field at runtime. This makes us to use field symbols as the alternative.
The table PA0001 is where the personel sub area for the hired employee is stored, so we will have to select the sub area from this table for the record who needs to be terminated. Issuing a select statement to find the personel sub area for and employee id (field PERNR) on table PA0001 would be
select single btrtl into sub_area where pernr = innnn-pernr.
Here btrtl is the sub area, sub_area is a user defined variable to store the value of the retrieved data and pernr is the personel number of the employee to be terminated. INNNN is a structure which has the field pernr. This structure is defined as importing in thr parameters so it can be accessed directly.
We know that the value of the subarea and position can not be assigned as they are not part of the exporting parameters in the defined Badi, so we will have t define two field symbols, which will be used to change the value at runtime. Field symbols are similar to pointers in C. They store the address of the variable it is assined to and when any change is made to the field symbol the value of the variable it is referencing is changed. Here we will have to know the program name,stucture and field name on which the changes need to be reflected. We find that the program name (via system->status) and the structure and field name via pressing F1 and clciking on technical information.We found the following for the subarea and postion.For subarea
Screen -
Structure - P0001
Field - BTRTL
For Position
Screen - MP000100
Structure - P0001
Field - PLANS
To access these fields in your program the format used is
Assign ('(screen name)structure name-fieldname') to field symbol.
So the following code would solve the purpose
data : sub_area type pa0001-btrtl.
field-.
select single btrtl from pa0001 into sub_area where pernr = innnn-pernr.
assign ('() to
endif.