Application Development 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: 

BDC

Former Member
0 Kudos

Hi All,

Pls let me know how to handle views while performing a bdc for MM01 transaction.

Regards,

Kavitha

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Kavitha,

Try recording the transaction MM01 using the transaction SHDB and generate the code for it.

Analyse the code, that might help you in understanding how the views are handled.

Regards,

Kiran

6 REPLIES 6

Former Member
0 Kudos

Hi Kavitha,

Try recording the transaction MM01 using the transaction SHDB and generate the code for it.

Analyse the code, that might help you in understanding how the views are handled.

Regards,

Kiran

Former Member
0 Kudos

Just keep pressing enter while recording.

it will record all the views.

Thanks & Regards

Edited by: daksh on Sep 16, 2008 3:30 AM

Former Member
0 Kudos

Hi kavitha,

after recording u will get following type of code for material views.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)' "BASIC1

'X'. " here we are passing "X" to select that view

perform bdc_field using 'MSICHTAUSW-KZSEL(02)' "BASIC2

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(04)' SALES1

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(05)' SALES2

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(06)' SALES3

'X'.

...

...

..

..

.

.

like this u can select other views .

While recording whatever views u selected that only will come in recording.

hope u r problem will solve.If not revert back.

Thanks & regards,

Sanket.

Former Member
0 Kudos

this is the sample code for xd01 try the same for mm01

DATA: BEGIN OF ITAB_KAN1 OCCURS 0,

KUNNR TYPE KNa1-KUNNR,

KTOKD TYPE KNA1-KTOKD,

ANRED TYPE KNA1-ANRED ,

NAME1 TYPE KNA1-NAME1,

SORTL TYPE KNA1-SORTL,

ORT01 TYPE KNA1-ORT01,

PSTLZ TYPE KNA1-PSTLZ,

LAND1 TYPE KNA1-LAND1,

SPRAS TYPE KNA1-SPRAS,

END OF ITAB_KAN1.

PARAMETER: P_FILE TYPE STRING.

DAta: IT_BDCDATA TYPE BDCDATA OCCURS 0,

WA_BDCDATA TYPE BDCDATA.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = P_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = ITAB_KAN1

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT ITAB_KAN1.

perform bdc_dynpro using 'SAPMF02D' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KTOKD'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02D-KUNNR'

ITAB_KAN1-KUNNR.

perform bdc_field using 'RF02D-KTOKD'

ITAB_KAN1-KTOKD.

perform bdc_dynpro using 'SAPMF02D' '0110'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-SPRAS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNA1-ANRED'

ITAB_KAN1-ANRED.

perform bdc_field using 'KNA1-NAME1'

ITAB_KAN1-NAME1.

perform bdc_field using 'KNA1-SORTL'

ITAB_KAN1-SORTL.

perform bdc_field using 'KNA1-ORT01'

ITAB_KAN1-ORT01.

perform bdc_field using 'KNA1-PSTLZ'

ITAB_KAN1-PSTLZ.

perform bdc_field using 'KNA1-LAND1'

ITAB_KAN1-LAND1.

perform bdc_field using 'KNA1-SPRAS'

ITAB_KAN1-SPRAS.

perform bdc_dynpro using 'SAPMF02D' '0120'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

CALL TRANSACTION 'XD01' USING IT_BDCDATA MODE 'A' UPDATE 'S'.

PERFORM BDC_SESSION.

ENDLOOP.

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR WA_BDCDATA.

WA_BDCDATA-PROGRAM = PROGRAM.

WA_BDCDATA-DYNPRO = DYNPRO.

WA_BDCDATA-DYNBEGIN = 'X'.

APPEND WA_BDCDATA TO IT_BDCDATA.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

CLEAR WA_BDCDATA.

WA_BDCDATA-FNAM = FNAM.

WA_BDCDATA-FVAL = FVAL.

APPEND WA_BDCDATA TO IT_BDCDATA.

ENDFORM.

*include bdcrecx1.

*

*parameters: dataset(132) lower case.

        • DO NOT CHANGE - the generated data section - DO NOT CHANGE ***

**

    • If it is nessesary to change the data section use the rules:

    • 1.) Each definition of a field exists of two lines

    • 2.) The first line shows exactly the comment

    • '* data element: ' followed with the data element

    • which describes the field.

    • If you don't have a data element use the

    • comment without a data element name

    • 3.) The second line shows the fieldname of the

    • structure, the fieldname must consist of

    • a fieldname and optional the character '_' and

    • three numbers and the field length in brackets

    • 4.) Each field must be type C.

**

        • Generated data section with specific formatting - DO NOT CHANGE ***

*data: begin of record,

    • data element: KUN16

  • KUNNR_001(016),

    • data element: KTOKD

  • KTOKD_002(004),

    • data element: ANRED

  • ANRED_003(015),

    • data element: NAME1_GP

  • NAME1_004(035),

    • data element: SORTL

  • SORTL_005(010),

    • data element: ORT01_GP

  • ORT01_006(035),

    • data element: PSTLZ

  • PSTLZ_007(010),

    • data element: LAND1_GP

  • LAND1_008(003),

    • data element: SPRAS

  • SPRAS_009(002),

  • end of record.

*

        • End generated data section ***

*

*start-of-selection.

*

*perform open_dataset using dataset.

*perform open_group.

*

*do.

*

*read dataset dataset into record.

*if sy-subrc <> 0. exit. endif.

*

*perform bdc_dynpro using 'SAPMF02D' '0100'.

*perform bdc_field using 'BDC_CURSOR'

  • 'RF02D-KTOKD'.

*perform bdc_field using 'BDC_OKCODE'

  • '/00'.

*perform bdc_field using 'RF02D-KUNNR'

  • record-KUNNR_001.

*perform bdc_field using 'RF02D-KTOKD'

  • record-KTOKD_002.

*perform bdc_dynpro using 'SAPMF02D' '0110'.

*perform bdc_field using 'BDC_CURSOR'

  • 'KNA1-SPRAS'.

*perform bdc_field using 'BDC_OKCODE'

  • '/00'.

*perform bdc_field using 'KNA1-ANRED'

  • record-ANRED_003.

*perform bdc_field using 'KNA1-NAME1'

  • record-NAME1_004.

*perform bdc_field using 'KNA1-SORTL'

  • record-SORTL_005.

*perform bdc_field using 'KNA1-ORT01'

  • record-ORT01_006.

*perform bdc_field using 'KNA1-PSTLZ'

  • record-PSTLZ_007.

*perform bdc_field using 'KNA1-LAND1'

  • record-LAND1_008.

*perform bdc_field using 'KNA1-SPRAS'

  • record-SPRAS_009.

*perform bdc_dynpro using 'SAPMF02D' '0120'.

*perform bdc_field using 'BDC_CURSOR'

  • 'KNA1-LIFNR'.

*perform bdc_field using 'BDC_OKCODE'

  • '=UPDA'.

*perform bdc_transaction using 'XD01'.

*

*enddo.

*

*perform close_group.

*perform close_dataset using dataset.

&----


*& Form BDC_SESSION

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BDC_SESSION .

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

  • DEST = FILLER8

GROUP = 'SESS'

  • HOLDDATE = FILLER8

KEEP = 'X'

USER = SY-UNAME

  • RECORD = FILLER1

  • PROG = SY-CPROG

  • DCPFM = '%'

  • DATFM = '%'

  • IMPORTING

  • QID = QID

EXCEPTIONS

CLIENT_INVALID = 1

DESTINATION_INVALID = 2

GROUP_INVALID = 3

GROUP_IS_LOCKED = 4

HOLDDATE_INVALID = 5

INTERNAL_ERROR = 6

QUEUE_ERROR = 7

RUNNING = 8

SYSTEM_LOCK_ERROR = 9

USER_INVALID = 10

OTHERS = 11

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'XD01'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

DYNPROTAB = IT_BDCDATA

EXCEPTIONS

INTERNAL_ERROR = 1

NOT_OPEN = 2

QUEUE_ERROR = 3

TCODE_INVALID = 4

PRINTING_INVALID = 5

POSTING_INVALID = 6

OTHERS = 7

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

NOT_OPEN = 1

QUEUE_ERROR = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " BDC_SESSION

Former Member
0 Kudos

Hi kavitha fredrick,

The Views in MM01 can be handled by press PgDn button and select wht ever Views this will help out.

Once answer plz do close the thread.

Regards,

sg

Former Member
0 Kudos

Hi, each page view has its own code, please follow the belo source code and do some testing, and then you can understand.

PERFORM click_next_view_tab USING '4000' '=SP18'. " click plant data/stor2

          • plant data/stor2 view

PERFORM click_next_view_tab USING '4000' '=SP21'. " click quality management

          • quality management view

PERFORM click_next_view_tab USING '4000' '=SP22'. " click accounting 1

          • accounting 1 view

PERFORM click_next_view_tab USING '4000' '=SP23'. " click accounting 2

          • accounting 2 view

  • PERFORM click_next_view_tab USING '4000' '=SP24'. " click costing 1

          • costing 1 view

PERFORM click_next_view_tab USING '4000' '=SP25'. " click costing 2