How can i create orgnsiation structure in sap
Hi Guys
Can anybody tell me how to craete an organsation strucuture first when first implimenting the sap in your company...step by step answer
thankx
Edited by: madhubabu rao on Jun 12, 2008 1:10 PM
Hi,
I have some code which I developed.
*& Form Create_operation_unit
* This subroutine is for creation of Operating Unit
FORM create_operation_unit .
* DATA:lv_valto TYPE datab.
DATA:
* lv_desc TYPE bapiset_hier-descript,
lv_gpname TYPE bapiset_hier-groupname,
lv_legno TYPE cepc-zzleg_no.
TYPES : BEGIN OF st_dept,
ww007 TYPE t25f4-ww007,
bezek TYPE t25f4-bezek,
END OF st_dept.
DATA: lt_dept TYPE TABLE OF st_dept.
DATA: wa_dept LIKE LINE OF lt_dept,
lv_lock_ind type cepc-lock_ind,
lv_segment type cepc-segment.
DATA: lv_index TYPE sy-tabix.
DATA: lv_index1 TYPE sy-tabix,
lv_prctr TYPE cepc-prctr,
lv_zsgid TYPE zfpasgid,
lv_zsgid_prev TYPE zfpasgid.
DATA: lv_indicators TYPE bapi0015_8.
IF p_sd_pct IS NOT INITIAL. "For Profit Center Group.
CLEAR: gt_hierarchy,gt_hierarchy[].
CLEAR: gt_hierarchy1,gt_hierarchy1[].
CLEAR: gt_value,gt_value[].
CLEAR: gt_value1,gt_value1[].
GET PARAMETER ID 'CAC' FIELD gv_p_kokrs.
IF gv_p_kokrs IS INITIAL.
CALL TRANSACTION 'OKKS'.
GET PARAMETER ID 'CAC' FIELD gv_p_kokrs.
ENDIF.
lv_index = 1.
lv_index1 = 2.
* Get deatils of lower levels group from target.
CALL FUNCTION 'BAPI_PROFITCENTERGRP_GETDETAIL'
EXPORTING
controllingarea = gv_p_kokrs
groupname = p_sd_pct
TABLES
hierarchynodes = gt_hierarchy
hierarchyvalues = gt_value.
***Get company code for profit center.
IF gt_value[] IS NOT INITIAL.
SELECT bukrs
FROM csks INTO TABLE gt_csks1
FOR ALL ENTRIES IN gt_value
WHERE prctr = gt_value-valfrom.
ENDIF.
LOOP AT gt_csks1 INTO wa_csks1.
wa_co_code-comp_code = wa_csks1-bukrs.
wa_co_code-assign_to_prctr = 'X'.
APPEND wa_co_code TO gt_co_code.
ENDLOOP.
SELECT ww007 bezek FROM t25f4 INTO TABLE lt_dept
WHERE spras = sy-langu.
LOOP AT lt_dept INTO wa_dept.
READ TABLE gt_hierarchy INTO wa_hierarchy WITH KEY groupname+7(3) = wa_dept-ww007+5(3).
IF ( wa_dept-ww007(4) = p_sd_pct AND wa_dept-ww007+5(3) = wa_hierarchy-groupname+7(3) ).
lv_gpname = wa_hierarchy-groupname.
wa_hierarchy-descript = wa_dept-bezek.
MODIFY gt_hierarchy FROM wa_hierarchy
TRANSPORTING descript
WHERE groupname = lv_gpname.
ENDIF.
ENDLOOP.
* Get the Lock indicator and segmant from source Operting unit.
SELECT lock_ind
segment
FROM cepc
INTO (lv_lock_ind,
lv_segment)
BYPASSING BUFFER
WHERE datbi GE sy-datum
AND kokrs = gv_p_kokrs
AND KHINR = p_sd_pct. "cepc values for source group
endselect.
READ TABLE gt_hierarchy INTO wa_hierarchy WITH KEY groupname = p_sd_pct.
* gv_tgt_level = wa_hierarchy-hierlevel - 1. "chain level
gv_src_level = wa_hierarchy-hierlevel. "Operating unit level
gv_dep_level = wa_hierarchy-hierlevel + 1. "department level.
LOOP AT gt_hierarchy INTO wa_hierarchy.
IF wa_hierarchy-hierlevel = gv_src_level. "Opearing Unit node
wa_hierarchy1-groupname = p_dsno.
* wa_hierarchy1-descript = wa_hierarchy-descript.
wa_hierarchy1-descript = p_name.
wa_hierarchy1-hierlevel = wa_hierarchy-hierlevel.
APPEND wa_hierarchy1 TO gt_hierarchy1.
ENDIF.
IF wa_hierarchy-hierlevel = gv_dep_level. "Department node
CONCATENATE p_dsno wa_hierarchy-groupname+7(3) INTO gv_ngrname.
wa_hierarchy1-groupname = gv_ngrname.
* wa_hierarchy1-descript = wa_hierarchy-descript.
wa_hierarchy1-descript = wa_hierarchy-descript.
wa_hierarchy1-hierlevel = wa_hierarchy-hierlevel.
APPEND wa_hierarchy1 TO gt_hierarchy1.
ENDIF.
CLEAR wa_hierarchy1.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM gt_hierarchy1
COMPARING groupname.
*---BEGIN Create profit center group
CALL FUNCTION 'BAPI_PROFITCENTERGRP_CREATE'
EXPORTING
controllingareaimp = gv_p_kokrs
IMPORTING
return = wa_message
TABLES
hierarchynodes = gt_hierarchy1
hierarchyvalues = gt_value1.
IF wa_message IS INITIAL.
CONCATENATE p_dsno text-020
INTO wa_message-message
SEPARATED BY space.
APPEND wa_message TO gt_message.
* Add node only if PCGroup is created successfully
*---BEGIN Add node to profit center group
CALL FUNCTION 'BAPI_PROFITCENTERGRP_ADDNODE'
EXPORTING
controllingarea = gv_p_kokrs
groupname = p_tg_pct
subgroupname = p_dsno
IMPORTING
return = wa_message.
IF wa_message IS INITIAL.
CONCATENATE p_dsno text-021 p_tg_pct
INTO wa_message-message
SEPARATED BY space.
APPEND wa_message TO gt_message.
*---Create Profit Center ONLY if PCgroup and ADD node created.
gv_pcgroup_created = 'X'. "flag used while Creating Profit Centers
*---Cost center group cration based on successful PC group creation.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
APPEND wa_message TO gt_message.
ENDIF.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
*---END Add node
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
APPEND wa_message TO gt_message.
ENDIF.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[].
*---END PC Group Create
ENDIF. "end For Profit Center Group.
IF p_sd_cct IS NOT INITIAL AND gv_pcgroup_created EQ 'X'. "For Cost Center Group.ONLY when PC group creation is successful
CLEAR: gt_hierarchy,gt_hierarchy[].
CLEAR: gt_hierarchy1,gt_hierarchy1[].
CLEAR: gt_value,gt_value[].
CLEAR: gt_value1,gt_value1[].
* Get deatils of lower levels group from target.
CALL FUNCTION 'BAPI_COSTCENTERGROUP_GETDETAIL'
EXPORTING
controllingarea = gv_p_kokrs
groupname = p_sd_cct
TABLES
hierarchynodes = gt_hierarchy
hierarchyvalues = gt_value.
READ TABLE gt_value INTO wa_value INDEX 1.
IF sy-subrc = 0.
SELECT SINGLE kokrs khinr bukrs kosar
FROM csks
INTO (gv_c_kokrs, gv_c_grpname, gv_c_bukrs, gv_kosar)
WHERE kokrs = gv_p_kokrs
AND kostl = wa_value-valfrom
AND datbi GE sy-datum.
ENDIF.
LOOP AT lt_dept INTO wa_dept.
READ TABLE gt_hierarchy INTO wa_hierarchy WITH KEY groupname+7(3) = wa_dept-ww007+5(3).
IF ( wa_dept-ww007(4) = p_sd_cct AND wa_dept-ww007+5(3) = wa_hierarchy-groupname+7(3) ).
lv_gpname = wa_hierarchy-groupname.
wa_hierarchy-descript = wa_dept-bezek.
MODIFY gt_hierarchy FROM wa_hierarchy
TRANSPORTING descript
WHERE groupname = lv_gpname.
ENDIF.
ENDLOOP.
READ TABLE gt_hierarchy INTO wa_hierarchy WITH KEY groupname = p_sd_cct.
* gv_tgt_level = wa_hierarchy-hierlevel - 1. "chain level
gv_src_level = wa_hierarchy-hierlevel. "Operating unit level
gv_dep_level = wa_hierarchy-hierlevel + 1. "department level.
LOOP AT gt_hierarchy INTO wa_hierarchy.
IF wa_hierarchy-hierlevel = gv_src_level. "Operating Unit node
wa_hierarchy1-groupname = p_dsno.
* wa_hierarchy1-descript = wa_hierarchy-descript.
wa_hierarchy1-descript = p_name.
wa_hierarchy1-hierlevel = wa_hierarchy-hierlevel.
APPEND wa_hierarchy1 TO gt_hierarchy1.
ENDIF.
IF wa_hierarchy-hierlevel = gv_dep_level. "Department node
CONCATENATE p_dsno wa_hierarchy-groupname+7(3) INTO gv_ngrname.
wa_hierarchy1-groupname = gv_ngrname.
* wa_hierarchy1-descript = wa_hierarchy-descript.
wa_hierarchy1-descript = wa_hierarchy-descript.
wa_hierarchy1-hierlevel = wa_hierarchy-hierlevel.
APPEND wa_hierarchy1 TO gt_hierarchy1.
ENDIF.
CLEAR wa_hierarchy1.
ENDLOOP.
*Create Cost Center Group
*---BEGIN of COSTCENTER Group CREATE
CALL FUNCTION 'BAPI_COSTCENTERGROUP_CREATE'
EXPORTING
*dinesh
controllingareaimp = gv_p_kokrs
IMPORTING
return = wa_message
TABLES
hierarchynodes = gt_hierarchy1
hierarchyvalues = gt_value1.
IF wa_message IS INITIAL.
CONCATENATE p_dsno text-022
INTO wa_message-message
SEPARATED BY space.
APPEND wa_message TO gt_message.
*Add node to cost center group ONLY if Cost Center Group creation is successful
*---BEGIN of ADDNODE
CALL FUNCTION 'BAPI_COSTCENTERGROUP_ADDNODE'
EXPORTING
*dinesh
controllingarea = gv_p_kokrs
groupname = p_tg_cct
subgroupname = p_dsno
IMPORTING
return = wa_message.
IF wa_message IS INITIAL.
CONCATENATE p_dsno text-023 p_tg_cct
INTO wa_message-message
SEPARATED BY space.
APPEND wa_message TO gt_message.
* Cost Center is created ONLY if Cost Center group and add node is successful
gv_ccgroup_created = 'X'. "flag used while crateing cost center
ELSE.
*Rollback if BAPI fails in Adding Node
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
APPEND wa_message TO gt_message.
ENDIF.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
*---END of ADDNODE
ELSE.
*Rollback if BAPI fails in creating group
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
APPEND wa_message TO gt_message.
ENDIF.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
*---END of COSTCENTER CREATE
ENDIF. "End of Cost Center Group
LOOP AT gt_hierarchy1 INTO wa_hierarchy1.
CLEAR: wa_profitcenterid,wa_basicdata,wa_address.
CLEAR: wa_costcenterlist,gt_costcenterlist,gt_costcenterlist[].
***Call function get_next_numbers to generate profit center no.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '02'
object = 'COPCA_OBJ'
IMPORTING
number = gv_number
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
IF sy-subrc <> 0.
IF sy-subrc = 8.
wa_message-id = sy-msgid.
wa_message-type = sy-msgty.
wa_message-number = sy-msgno.
wa_message-message_v1 = sy-msgv1.
wa_message-message_v2 = sy-msgv2.
wa_message-message_v3 = sy-msgv3.
wa_message-message_v4 = sy-msgv4.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSEIF sy-subrc = 1.
wa_message-message_v1 = text-043.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSEIF sy-subrc = 2.
wa_message-message_v1 = text-044.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSEIF sy-subrc = 3.
wa_message-message_v1 = text-045.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSEIF sy-subrc = 4.
wa_message-message_v1 = text-046.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSEIF sy-subrc = 5.
wa_message-message_v1 = text-047.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSEIF sy-subrc = 6.
wa_message-message_v1 = text-048.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[].
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSEIF sy-subrc = 7.
wa_message-message_v1 = text-049.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ELSE.
IF p_sd_pct IS NOT INITIAL. "For Profit Center create.
*Create Profit Center only when Profit center group creation and add node is successful
IF gv_pcgroup_created = 'X'. "PCG flag check
clear: wa_profitcenterid,
wa_basicdata,
wa_address,
lv_indicators.
wa_profitcenterid-co_area = gv_p_kokrs.
wa_profitcenterid-profit_ctr = gv_number.
wa_basicdata-prctr_name = wa_hierarchy1-groupname.
wa_basicdata-long_text = wa_hierarchy1-descript.
wa_basicdata-in_charge = sy-uname.
wa_basicdata-prctr_hier_grp = wa_hierarchy1-groupname.
wa_basicdata-segment = lv_segment.
IF wa_hierarchy1-hierlevel = gv_src_level. "Address and locking only in Op.Unit
lv_indicators-LOCK_IND = lv_lock_ind.
wa_address-name = p_name.
wa_address-street = p_strt.
wa_address-city = p_city.
wa_address-postl_code = p_pcod.
wa_address-country = p_cont.
wa_address-region = p_reg.
ENDIF.
* Create Profit Center
* WAIT UP TO 2 SECONDS.
CALL FUNCTION 'BAPI_PROFITCENTER_CREATE'
EXPORTING
profitcenterid = wa_profitcenterid
validfrom = p_date
validto = c_validto
basicdata = wa_basicdata
address = wa_address
indicators = lv_indicators
IMPORTING
return = wa_message
TABLES
companycodes = gt_co_code.
* WAIT UP TO 2 SECONDS.
IF wa_message-type NE 'E' OR wa_message-type NE 'A'.
CONCATENATE wa_profitcenterid-profit_ctr text-024
INTO wa_message-message
SEPARATED BY space.
APPEND wa_message TO gt_message.
ELSE.
CLEAR gv_pcgroup_created. "CEPC updation is based on this
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
APPEND wa_message TO gt_message.
ENDIF.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
ENDIF . "end of flag check
ENDIF. "end of profitcenter create
IF p_sd_cct IS NOT INITIAL. "For Cost Center Create.
*Create Cost Center only when Cost center group creation and add node is successful
IF gv_ccgroup_created = 'X'. "CCG flag check
IF wa_hierarchy1-hierlevel = gv_dep_level. "Cost Center only in Dept level
READ TABLE gt_value INTO wa_value INDEX lv_index1.
SELECT kostl kosar FROM csks
INTO TABLE gt_csks_cat
WHERE kostl = wa_value-valfrom.
lv_index1 = lv_index1 + 1.
READ TABLE gt_csks_cat INTO wa_csks_cat WITH KEY kostl = wa_value-valfrom.
wa_costcenterlist-costcenter = gv_number.
wa_costcenterlist-valid_from = p_date.
wa_costcenterlist-valid_to = c_validto. "31.12.9999
wa_costcenterlist-person_in_charge = sy-uname.
wa_costcenterlist-comp_code = gv_c_bukrs .
wa_costcenterlist-costcenter_type = wa_csks_cat-kosar.
wa_costcenterlist-costctr_hier_grp = wa_hierarchy1-groupname.
wa_costcenterlist-descript = wa_hierarchy1-descript.
wa_costcenterlist-name = wa_hierarchy1-groupname.
wa_costcenterlist-profit_ctr = gv_number.
APPEND wa_costcenterlist TO gt_costcenterlist.
*---BEGIN Create Cost Center
CALL FUNCTION 'BAPI_COSTCENTER_CREATEMULTIPLE'
EXPORTING
controllingarea = gv_p_kokrs
TABLES
costcenterlist = gt_costcenterlist
return = gt_message.
READ TABLE gt_message INTO wa_message INDEX 1.
CLEAR gt_message[].
IF wa_message-type = 'E' OR wa_message-type = 'A'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
CONCATENATE wa_message-message wa_message-message_v1 text-050 p_dsno text-051
INTO wa_message-message
SEPARATED BY space.
APPEND wa_message TO gt_message.
CLEAR: gt_message,gt_message[],wa_message.
ELSE.
* Activate only if Cost center is created successfully
*---BEGIN of ACTIVATION
CLEAR : wa_costcenterlist_act,gt_costcenterlist_act[].
wa_costcenterlist_act-co_area = gv_p_kokrs.
wa_costcenterlist_act-costcenter = gv_number.
wa_costcenterlist_act-name = p_name.
wa_costcenterlist_act-descript = wa_hierarchy1-descript.
wa_costcenterlist_act-act_state = 'X'.
APPEND wa_costcenterlist_act TO gt_costcenterlist_act.
CALL FUNCTION 'BAPI_CTR_ACTIVATE_MULTIPLE'
EXPORTING
controllingarea = gv_p_kokrs
TABLES
costcenterlist = gt_costcenterlist_act
return = gt_message.
READ TABLE gt_message INTO wa_message INDEX 1.
IF wa_message-type = 'E' OR wa_message-type = 'A'.
CLEAR gv_ccgroup_created. "CEPC updation is based on this condition
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
CONCATENATE p_dsno text-050
INTO wa_message-message
SEPARATED BY space.
APPEND wa_message TO gt_message.
ELSE.
CONCATENATE wa_profitcenterid-profit_ctr text-025 text-026
INTO wa_message-message
SEPARATED BY space.
APPEND wa_message TO gt_message.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. "COMMIT CC activation
ENDIF.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
*---END of ACTIVATION
ENDIF.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
*---END Create Cost Center
ENDIF.
ENDIF. "end of CCG flag check
ENDIF. "end of cost center create
*--Updating CEPC Append Structure ZDSG_DATA and sales group table ZFPASALESGROUP
IF gv_ccgroup_created = 'X' AND gv_pcgroup_created = 'X'.
READ TABLE gt_hierarchy
INTO wa_hierarchy
WITH KEY hierlevel = wa_hierarchy1-hierlevel. "source group
IF sy-subrc = 0.
*CEPC values for source group
READ TABLE gt_value INTO wa_value INDEX lv_index.
SELECT SINGLE * FROM cepc
INTO wa_cepc BYPASSING BUFFER
WHERE kokrs = gv_p_kokrs
AND datbi GE sy-datum
AND prctr = wa_value-valfrom.
* For updating CEPC
IF sy-subrc = 0.
READ TABLE gt_hierarchy INDEX lv_index
INTO wa_hierarchy.
lv_index = lv_index + 1.
IF wa_hierarchy-hierlevel = 1.
CONCATENATE p_legacy wa_hierarchy-groupname+7(3) INTO lv_legno.
p_ztype = '05'.
p_zstype = ' '.
ELSE.
lv_legno = p_legacy.
ENDIF.
wa_cepc-prctr = gv_number.
wa_cepc-datbi = c_validto.
wa_cepc-kokrs = gv_p_kokrs.
wa_cepc-zzleg_no = lv_legno.
wa_cepc-zztype = p_ztype.
wa_cepc-zzstype = p_zstype.
wa_cepc-zzfsdate = p_sal_da.
wa_cepc-zzdist = p_zdist.
wa_cepc-zzsvat = p_zsvat.
APPEND wa_cepc TO gt_cepc.
PERFORM update_append_cepc TABLES gt_cepc.
CLEAR:wa_cepc,gt_cepc[],gt_cepc,lv_prctr.
* For updating ZFPASALESGROUP
SELECT SINGLE prctr
INTO lv_prctr
FROM cepc
WHERE khinr = wa_hierarchy-groupname.
IF sy-subrc = 0.
SELECT * FROM zfpasalesgroup
INTO TABLE gt_salesgrp
WHERE zvalid_from GE p_date
AND zvalid_to LE c_validto
AND prctr = lv_prctr
AND zdeactive = ''.
IF sy-subrc = 0.
SELECT MAX( zsgid ) INTO lv_zsgid FROM zfpasalesgroup.
IF lv_zsgid IS INITIAL.
lv_zsgid = '1000000000'.
ENDIF.
SORT gt_salesgrp BY zsgid zvalid_from.
LOOP AT gt_salesgrp INTO wa_salesgrp.
IF lv_zsgid_prev NE wa_salesgrp-zsgid OR lv_zsgid_prev IS INITIAL.
* wa_salesgrp-zsgid = lv_zsgid.
* else.
lv_zsgid = lv_zsgid + 1.
lv_zsgid_prev = wa_salesgrp-zsgid.
wa_salesgrp-zsgid = lv_zsgid.
ELSE.
* lv_zsgid_prev = lv_zsgid.
wa_salesgrp-zsgid = lv_zsgid.
ENDIF.
wa_salesgrp-prctr = gv_number.
IF wa_salesgrp-zvalid_from LT p_date.
wa_salesgrp-zvalid_from = p_date.
ENDIF.
* wa_salesgrp-zvalid_to = c_validto.
* insert new entry in zfpasalesgroup for data entered on screen.
INSERT into zfpasalesgroup values wa_salesgrp.
* MODIFY zfpasalesgroup FROM TABLE gt_salesgrp .
* Message for output
IF sy-subrc = 0.
CONCATENATE wa_salesgrp-zsgid text-102 'ZFPASALESGROUP'
INTO wa_message-message
SEPARATED BY space.
wa_message-type = 'S'.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
ELSE.
* Message for output if its not successful
CONCATENATE text-103 'ZFPASALESGROUP'
INTO wa_message-message
SEPARATED BY space.
wa_message-type = 'E'.
APPEND wa_message TO gt_message.
PERFORM output CHANGING gt_message.
CLEAR: gt_message,gt_message[],wa_message.
ENDIF.
CLEAR wa_salesgrp.
ENDLOOP.
CLEAR: wa_salesgrp, gt_salesgrp[], gt_salesgrp,lv_zsgid_prev .
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
PERFORM display_log CHANGING gt_log.
PERFORM clear_variables.
gv_active_tab = 'SOS_TAB1'.
ENDFORM. " Create_operation_unit
<REMOVED BY MODERATOR>
Regards
Susheel
Code Formatted by: Alvaro Tejada Galindo on Jun 12, 2008 4:31 PM
Similar Messages
-
How can i create Organization Structure in sap
Hi Abaper/Basis Guys...
I want To Create An Simple Basic Organization Structure for my small Company..iam Abaper no basic guy is there in my office.
pls send me step by step guidlines
Thank You.
Madhu Rao
Edited by: madhubabu rao on Jun 19, 2008 8:01 AMHi Madhu,
Kindly check the following links.
http://help.sap.com/saphelp_nw2004s/helpdata/en/4b/6a43cccafe11d2b49d006094b9c9b4/content.htm
http://help.sap.com/bestpractices/BBLibrary/html/J02_OrgStructure_EN_UK.htm
Dont forget to reward points if found useful.
Thanks,
Satyesh -
How can we creat web-dynpro in SAP 4.6c?
Hi Gurus,
I'm new to the Web-dynpro technology, please help me in creating a simple web-dynpro.
My questions are:
1. can we create web-dynpro in SAP version 4.6c?
2. If yes then how?Hi Manjesh,
You cannt develop Web Dynpro's in 4.6C version. Web Dynpro's are introduced from ECC6.0 onwords.
Check this document about Web Dynpro for ABAP
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/77/3545415ea6f523e10000000a155106/content.htm
Edited by: suman kumar chinnam on Oct 17, 2008 12:51 PM -
How can we create cost centres in SAP B1
please advise how we can create cost centres in SA P-B1 as we do in tally.
Hi
You can Download the e-learning File in SAP Customer portal regarding cost Accounting
Go to [http://service.sap.com]
Customer portal =>Education=>Release 2007 => Finance=> cost and Budgeting
Regards
Balaji -
How can we create web shop in sap crm 4.0 version
hi, crm gurus, plz anser my question.
thanks in advanceHi!
A good step-by-step guide is the Best Practices guides.
The BP for CRM4 is available at help.sap.com or
<a href="http://help.sap.com/bp_crmv340/CRM_DE/index.htm">here</a>
rollo -
How can mass creating production orders???
In SAP ,we can use CO01,CO09,CO07 to create production order. But by these TOCDES,we only can create one production order for one finished product once a time.
But we now need to create more then one ,may be more then 50 production orders once a time?
It is possible in SAP?
I know we could conver the production orders from plan orders after MRP run.But sometimes
for some reasons we must create produciton orders manually.And I also know in SAP some TCODE can process many production orders once a time ,like COHV,CORM, can release ,TECO many production orders once a time.
But how can mass creating production orders once a time,not by mrp run?
How can batch create produciton orders in SAP?
Thanks for any reply!Hi,
Use the BAPI - BAPI_PRODORD_CREATE or for internal orders BAPI_INTERNALORDER_CREATE
Take the help of your abaper, he / she can use the above BAPI to write a custom program to mass create production order.
Hope the above helps.
Regards,
Vivek
Added
You can also use the below BAPI's in your custom program:
BAPI_PRODORD_RELEASE to release the orders
BAPI_PRODORD_CHECK_MAT_AVAIL for carrying out material availability
Edited by: Vivek on Mar 22, 2009 8:27 PM -
How can I create more than one main window in a page of SAP SCRIPT?
How can I create more than one main window in a page of SAP SCRIPT? If anybody helps me I will be obliged.
Regards,
SubhasishHi Ganguly,
It is possible to have more than one main window in a same page.
You create a main window and simply you copy and past it in the same page.. it will create first main window name as MAIN and other main windows as MAIN01,MAIN02.... up to MAIN99.
Contets flow from MAIN , MAIN01, MAIN02.......................MAIN99. contents after filling the current window it flows to next window(by default, you skip as well with some keyword not sure could be NEW-WINDOW)
you want print the main window data twice? or you want to create two main window in the same page ?
1. give two copies in the no of copies in the output type screen ( Which pop up is coming after excute the program ).
2. create two page with the same script form.
3. you can write the coding inside the program to print twice the same page.
Hope this information use full to you.. -
How can I create a Commercial Invoice or similar document in SAP ByD?
How can I create a Commercial Invoice or similar document in SAP ByD?
Our company has recently implemented ByD, but we can't figure out how to create a commercial invoice for shipping/customs purposes. I know that the German version of ByD allows for "Export Declarations" which is pretty much the same as a commercial invoice, but the U.S. version doesn't have this document/function.
Any suggestions? I would appreciate any help.
By the way, a commercial invoice contains:
1. The shipperu2019s complete information: Contact name, company name, complete address and tax identification number.
2. The recipientu2019s complete information: Contact name, company name, complete address and phone number.
3. The buyeru2019s information (the person to whom the goods are sold by the seller) if different from the recipient: Contact name, company name, complete address and phone number.
4. The shipment tracking number, air waybill number or bar-code label number.
5. An accurate description of the contents in your shipment that includes the following details:
What the product is
What material the product is made of
What the productu2019s Schedule B or HTS code is
What the productu2019s intended use is
What the productu2019s country of manufacture is
What the productu2019s parts or serial numbers are (if applicable)
What the productu2019s quantity and unit of measure are
What the productu2019s value is, per unit and in total
Thanks,
ChrisMay I suggest that you ask this question in the customer forums in the Business Center at [http://sme.sap.com|http://sme.sap.com]
Best regards, Christian -
How can I create a new sales order template in SAP CRM 7.0
Hello,
how can I create a new sales order template in SAP CRM 7.0 (Web UI)? I want to use this sales order template in scenario ´'Mass Generation of Sales Orders via Marketing Projects'.
Thanks for your support in advance.
Best regards,
anvanHi,
Did you set up this scenario? I want something similar, but I want an ERP order to be created. Do you know if that is possible? Do you have som tips?
regards Camilla -
How can we create a data source on structures
Hi,
How can we create a data source on structures.
Regs,
abdulAbdul,
Welcome to SDN!
We can't create Datasource using Strcutres. We need to have base tables.
For Function Module Extractors, we will create strctures. We will use these strctures as Extract Structures. But, we will get the data from Base tables only not from Strcutures.
Strctures won't contain data.
all the best.
Regards,
Nagesh Ganisetti. -
How can i create a Laptop like the ones use in SAP TecEd?
How can i create a Laptop like the ones use in SAP TecEd hands on labs? with all the NW products install on it.
Hi,
Vague question, but to create a laptop with the solution installed - you need to order the solution and and then install it on the laptop. Or download trial versions from SCN and install those as well.
Regards,
Srikishan -
Hello friends
We don't have a Basis guy here. I am an XI certified person wearing different caps. I am trying to append a structure to VBAK and when I try to make the change it is asking for access key.
I looked at other SDN postings regarding this but unfortunately couldn't get much help.
I have created the devolopers key by going to http://service.sap.com/sscr.
But this key doesn't work when I try to use as access key. How can i create an access key.
If anybody has step by step procedure and can share it with me, I will appreciate it.
Thanks
RamYou have to register object change in the SSCR for the access key.
Hope this will help you.
AT -
How can I send purchase order through SAP mail ?
How can I send purchase order through SAP mail ? Can any one explain whts the NACE settings?
just do it as <b>Anji reddy</b> said to you ...or else ... in the purchase order trascation ...print it ... so that it will generate the spool request for that purchase order ....
so the the belwo program is for sending <b>the Spool Request data as Email to any Email id ...</b>
The code below demonstrates how to retrieve a spool request and email it as a PDF document. Please note for the below program to process a spool request the program must be executed in background otherwise no spool request will be created. Once you have had a look at this there is an modified version of the program which works in both background and foreground. Also see transaction SCOT for SAPConnect administration.
*& Report ZSPOOLTOPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
* Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
* Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
* Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
* Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
* Write statement to represent report output. Spool request is created
* if write statement is executed in background. This could also be an
* ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
*** Alternative way could be to submit another program and store spool
*** id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
* to sap-spool
* spool parameters %_print
* archive parameters %_print
* without spool dynpro
* and return.
* Get spool id from program called above
* IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
* FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
* FORM get_job_details *
FORM get_job_details.
* Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
* FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
* Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
* FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
* perform send_email using p_email2.
ENDFORM.
* FORM send_email *
* --> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
* Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
* CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
* If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
* Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
* FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
* Fill the document data.
w_doc_data-doc_size = 1.
* Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
* Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
* Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
* Populate zerror return code
ld_error = sy-subrc.
* Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
Girish -
How can i create a substitution in OBBH?
Hi.
I want to use a exit with " exits-param = C_EXIT_PARAM_CLASS." in T-code "OBBH' to change the test of doc item.
I create the form and append this form into exits.
But now I find i can't create a step in "complete document".
Message:
You may not substitute any fields for this Event
Message no. GB175
Diagnosis
Although substitutions are permitted for the boolesche class 15 (application area FI, Event 0003), the application did not release any field for substitution.
System response
Processing is terminated. You cannot change any field for this Event (even within a substitution exit). Defining a substitute therefore makes no sense.
But my friend can create the Step in Complete document.
Please help me how can i create it ...Hi,
SAP limits the number of fields that you can use for substitution. If you want to use a field that SAP does not make available for substitution, you have to modify table GB01.
Regards,
Sridevi
<i>* Assign points, if useful</i> -
How can i create a Step in OBBH
Hi.
I want to use a exit with " exits-param = C_EXIT_PARAM_CLASS." in T-code "OBBH' to change the test of doc item.
I create the form and append this form into exits.
But now I find i can't create a step in "complete document".
Message:
You may not substitute any fields for this Event
Message no. GB175
Diagnosis
Although substitutions are permitted for the boolesche class 15 (application area FI, Event 0003), the application did not release any field for substitution.
System response
Processing is terminated. You cannot change any field for this Event (even within a substitution exit). Defining a substitute therefore makes no sense.
But my friend can create the Step in Complete document.
Please help me how can i create it ...Hi,
SAP limits the number of fields that you can use for substitution. If you want to use a field that SAP does not make available for substitution, you have to modify table GB01.
Regards,
Sridevi
<i>* Assign points, if useful</i>
Maybe you are looking for
-
hi, any one can give me definations of SALES OREDR,QUATATION,PURCHASE ORDER,INVOICE,DELIVERY,COMPANY CODE,SALES ORGANIZATION,PLANT,WARE HOUSE.
-
Hi Extending VO Currently "Medical Assessment Details" page does not include employee's phone numbers. Modification into "Medical Assessment Details" page to add employee's home and mobile phone numbers this is my Query SELECT papf.full_name , SUBSTR
-
Hi, I have configured the UWL and getting the message on Register "UWL System_Name Created Successfully", but the problem is that after configuration the UWL is not showing the work items. Please help me. Regards Deep
-
A airplanes B bruno mars E eminem
-
I have completed OCA certification. I gave 1Z0-147 (9i Program with PL/SQL) exam as the OCA Level-2 exam. I am now interested in giving the OCP certification. I wish to give *1Z0-146* (11g Advanced PL/SQL Developer) and wanted to know of any study ma