Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

help regarding bapi

Former Member
0 Likes
1,219

I HAVE WRITTEN THIS PROGRAM FOR CREATING ROUTING USING BAPI BAPI_ROUTING_CREATE .BUT IT IS NOT WORKING CAN ANYBODY SUGGEST ME.

*****************************************************************

*BAPI FOR CREATING ROUTING

*****************************************************************

REPORT zbapi_routing

NO STANDARD PAGE HEADING

LINE-SIZE 255

LINE-COUNT 62(4)

MESSAGE-ID zpp01.

************************************************************

*STRUCTURE DECLERATION

************************************************************

TABLES:

bapi1012_tsk_c , "Task list header data in CREATE-BAPI for routings

bapi1012_mtk_c , "Material task list assignment in CREATE-BAPI for

bapiret2 . "Return parameter

DATA:v_file TYPE string .

DATA :BEGIN OF routing_create_master ,

matnr TYPE matnr , "Material number

werks_d TYPE werks_d , "Plant

*PLNNR TYPE PLNNR , " Key for task list group

*plnal TYPE plnal , " Group counter

**TASK LIST

plnnr TYPE plnnr , " Key for task list group

*PLNAL TYPE PLNAL, " Group counter

datuv(8) TYPE c , " Valid-from date

datub(8) TYPE c , " Valid-to date

pln_verwe TYPE pln_verwe , "task list usage

*WERKS_D TYPE WERKS_D , " Plant

plnst TYPE plnst , "Status

plnme(3) TYPE c , "Task list unit of measure

isocd_unit TYPE isocd_unit , "ISO code for unit of measurement

losvn(13) TYPE c , "from lot size

losbs(13) TYPE c, "To lot size

plantext TYPE plantext , " Task list description

END OF routing_create_master .

**********************************************************************

  • INTERNAL TABLE DECLARATIONS *

**********************************************************************

DATA:BEGIN OF routing_master OCCURS 0.

INCLUDE STRUCTURE routing_create_master .

DATA :END OF routing_master .

DATA : BEGIN OF bapi_task_list OCCURS 0.

INCLUDE STRUCTURE bapi1012_tsk_c .

DATA : END OF bapi_task_list .

DATA :BEGIN OF bapi_t_assgn OCCURS 0.

INCLUDE STRUCTURE bapi1012_mtk_c .

DATA :END OF bapi_t_assgn.

DATA :BEGIN OF i_message OCCURS 0.

INCLUDE STRUCTURE bapiret2 .

DATA :END OF i_message.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_file LIKE rlgrap-filename

DEFAULT '' OBLIGATORY. " File Name

SELECTION-SCREEN END OF BLOCK b1.

*******************************************************************

*FILE UPLOADING

*******************************************************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

mask = '*.xls'

  • STATIC = 'X'

CHANGING

file_name = p_file

EXCEPTIONS

mask_too_long = 1

OTHERS = 2.

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.

  • Start of selection Event.............................

START-OF-SELECTION.

PERFORM upload_file TABLES routing_master

USING p_file.

***********************************************************************

    • DATA MAPPING *

***********************************************************************

SORT routing_master BY MATNR WERKS_D .

CLEAR routing_master .

CLEAR bapi_t_assgn .

CLEAR bapi_task_list .

LOOP AT ROUTING_MASTER .

MOVE ROUTING_MASTER-matnr TO bapi_t_assgn-MATERIAL .

MOVE ROUTING_MASTER-werks_d TO bapi_t_assgn-PLANT .

*MOVE ROUTING_MASTER-PLNNR TO bapi_t_assgn-PLNNR .

*

*MOVE ROUTING_MASTER-PLNNR TO bapi_t_assgn-PLNNR .

MOVE ROUTING_MASTER-datuv TO bapi_t_assgn-VALID_FROM .

MOVE ROUTING_MASTER-datub TO bapi_t_assgn-VALID_TO_DATE .

MOVE ROUTING_MASTER-datub TO bapi_task_list-VALID_TO_DATE .

MOVE ROUTING_MASTER-datuv TO bapi_task_list-VALID_FROM .

MOVE ROUTING_MASTER-pln_verwe TO bapi_task_list-TASK_LIST_USAGE .

MOVE ROUTING_MASTER-plnst TO bapi_task_list-TASK_LIST_STATUS .

MOVE ROUTING_MASTER-plnme TO bapi_task_list-TASK_MEASURE_UNIT .

MOVE ROUTING_MASTER-isocd_unit TO bapi_task_list-TASK_MEASURE_UNIT_ISO

.

MOVE ROUTING_MASTER-losvn TO bapi_task_list-LOT_SIZE_FROM .

MOVE ROUTING_MASTER-losbs TO bapi_task_list-LOT_SIZE_TO .

MOVE ROUTING_MASTER-plantext TO bapi_task_list-DESCRIPTION.

append bapi_task_list .

append bapi_t_assgn .

ENDLOOP.

BREAK-POINT.

*********************************************************

***CALL FUNCTION BAPI

*********************************************************

CALL FUNCTION 'BAPI_ROUTING_CREATE'

  • EXPORTING

  • TESTRUN = ' '

  • PROFILE =

  • BOMUSAGE =

  • APPLICATION =

  • IMPORTING

  • GROUP =

  • GROUPCOUNTER =

TABLES

task = bapi_task_list

MATERIALTASKALLOCATION = bapi_t_assgn

  • SEQUENCE =

  • OPERATION =

  • SUBOPERATION =

  • REFERENCEOPERATION =

  • WORKCENTERREFERENCE =

  • COMPONENTALLOCATION =

  • PRODUCTIONRESOURCE =

  • INSPCHARACTERISTIC =

  • TEXTALLOCATION =

  • TEXT =

RETURN = i_message

.

----


  • FORM UPLOAD_FILE *

----


  • ........ *

----


  • --> P_TABLE *

  • --> P_FILE *

----


FORM upload_file TABLES p_table

USING p_file.

  • Data Declarations.......................................

DATA : l_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.

DATA : l_index TYPE i.

DATA : l_start_col TYPE i VALUE '1',

l_start_row TYPE i VALUE '3',

l_end_col TYPE i VALUE '256',

l_end_row TYPE i VALUE '65536'.

  • Field Symbols...........................................

FIELD-SYMBOLS : <fs>.

CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

EXPORTING

filename = p_file

i_begin_col = l_start_col

i_begin_row = l_start_row

i_end_col = l_end_col

i_end_row = l_end_row

TABLES

intern = l_intern

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

.

IF sy-subrc NE 0.

  • MESSAGE E002(ZA). " File Error

FORMAT COLOR COL_BACKGROUND INTENSIFIED.

WRITE : / 'File Error'.

EXIT.

ENDIF.

IF l_intern[] IS INITIAL.

  • MESSAGE E003(ZA). " No Data Uploaded

FORMAT COLOR COL_BACKGROUND INTENSIFIED.

WRITE : / 'No Data Uploaded'.

EXIT.

ELSE.

SORT l_intern BY row col.

LOOP AT l_intern.

MOVE l_intern-col TO l_index.

ASSIGN COMPONENT l_index OF STRUCTURE p_table TO <fs>.

MOVE l_intern-value TO <fs>.

AT END OF row.

APPEND p_table.

CLEAR p_table.

ENDAT.

ENDLOOP.

ENDIF.

ENDFORM.

9 REPLIES 9
Read only

Former Member
0 Likes
1,121

Hello "JAMES BOND",

What is the error you get? Furthermor I can't see the function module BAPI_TRANSACTION_COMMIT which is obligatory for saving the data to the DB.

Regards,

John.

Read only

0 Likes
1,121

hello john,

now i have put BAPI_TRANSACTION_COMMIT

still i am not able to create routing.

there is no error in code but when i un it and upload my excel file and fill the enternal table .

please help me.

Read only

0 Likes
1,121

Hello,

Aren't there any entries in your table i_message after the BAPI has finished?

Regards,

John.

Read only

0 Likes
1,121

What's the value of sy-subrc after the BAPI?

Read only

0 Likes
1,121

Nothing at all. All errors/warnings are collected in the table RETURN.

Read only

Former Member
0 Likes
1,121

CAN ANYBODY HELP ME REGARDING BAPI BAPI_ROUTING_CREATE.

WHO HAS USED IT PLEASE HELP ME.

Read only

0 Likes
1,121

Hello,

You still haven't answered my question:Aren't there any entries in your table i_message after the BAPI has finished?

Regards,

John

Read only

0 Likes
1,121

Result of check lines:

E BA 001 0

E CP 211 Enter plant for task list 1

E CP 002 Create task list: Consistency check was not successful 1

A CP 210 For further processing, the routing entry is missing 0

THIS IS ERROR I AM GETTING.

Read only

0 Likes
1,121

The first line is quiet strange (message: Archiving and reorganization in progress. Logon not permitted).

However second line suggests there is no plant defined in your upload. Can't you find this error when debugging?

Regards,

John.