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

pls run this program

Former Member
0 Likes
437

Dear sir,

this is my bdc call transaction program using transaction code " MB1C".

its perfectly working...

in this program flat file contains 600 data.

this is normal logic...

Each data stored in one document number .

but program logic is

store only 300 data in only one document number.

next stored balance 300 in another one document number...

here below my program paste it.

pls change this program this logic...first store only 300 data in only one document number next store another 300 data in one document.....

pls help me sir...

its very important...

report ZMB1C_SAN

no standard page heading line-size 255.

TABLES:

MSEG,

MKPF,

rm07m,

dkacb.

DATA:

I_BDCMSGCOLL TYPE STANDARD TABLE OF BDCMSGCOLL WITH HEADER LINE, " Internal table to store messages from Call Transaction

IT_BDCTAB TYPE BDCDATA OCCURS 0 WITH HEADER LINE. " Internal table for BDC data

DATA :

BEGIN OF IT_DATA OCCURS 10,

matnr(30),

erfmg(30),

lgort(6),

END OF IT_DATA.

DATA: date(10) type c.

&----


&

  • SELECTION SCREEN.

&----


&

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER:

  • P_FILE type localfile obligatory.

P_FILE TYPE RLGRAP-FILENAME ." OBLIGATORY DEFAULT 'C:\MB1C.TXT'.

SELECTION-SCREEN END OF BLOCK B1.

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

  • Initialization

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

INITIALIZATION.

write : sy-datum to date dd/mm/yyyy no-gap.

&----


&

  • AT SELECTION SCREEN.

&----


&

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM FILE_HELP .

&----


&

  • START-OF-SELECTION

&----


&

START-OF-SELECTION.

PERFORM READ_INPUT_DATA.

LOOP AT IT_DATA.

REFRESH IT_BDCTAB.

PERFORM BDC_POPULATION.

*CLEAR: IT_BDCTAB, IT_DATA[].

PERFORM CALL_TRAN.

ENDLOOP.

----


  • END OF SELECTION.

----


END-OF-SELECTION.

----


  • Form : FILE_HELP

----


FORM FILE_HELP .

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = P_FILE.

ENDFORM.

.

FORM READ_INPUT_DATA.

DATA: L_FILE TYPE STRING.

L_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = L_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = it_data.

  • 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.

ENDFORM.

----


  • Form : BDC_POPULATION

----


***include bdcrecx1.

***

*

*perform open_group.

FORM BDC_POPULATION.

perform bdc_dynpro using 'SAPMM07M' '0400'.

perform bdc_field using 'BDC_CURSOR'

'RM07M-LGORT'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MKPF-BLDAT'

date.

perform bdc_field using 'MKPF-BUDAT'

date.

perform bdc_field using 'RM07M-BWARTWA' "Movement type

'561'.

perform bdc_field using 'RM07M-WERKS' "plant

'1000'.

perform bdc_field using 'XFULL'

'X'.

perform bdc_field using 'RM07M-WVERS2'

'X'.

perform bdc_dynpro using 'SAPMM07M' '0421'.

perform bdc_field using 'BDC_CURSOR'

'MSEG-LGORT(01)'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'MSEG-MATNR(01)' "Material

it_data-matnr.

perform bdc_field using 'MSEG-ERFMG(01)' "Quatity

it_data-erfmg.

perform bdc_field using 'MSEG-LGORT(01)' "S Loc

it_data-lgort.

perform bdc_field using 'DKACB-FMORE'

'X'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

*perform bdc_transaction using 'MB1C'.

*perform close_group.

ENDFORM.

----


  • Start new screen *

----


form bdc_dynpro using program dynpro.

clear it_bdctab.

it_bdctab-program = program.

it_bdctab-dynpro = dynpro.

it_bdctab-dynbegin = 'X'.

append it_bdctab.

endform.

----


  • Insert field *

----


form bdc_field using fnam fval.

  • if fval <> nodata.

clear it_bdctab.

it_bdctab-fnam = fnam.

it_bdctab-fval = fval.

append it_bdctab.

  • endif.

endform.

&----


*& Form CALL_TRAN

&----


form CALL_TRAN .

DATA: W_MODE TYPE C VALUE 'A'.

CALL TRANSACTION 'MB1C' USING IT_BDCTAB MODE W_MODE MESSAGES INTO I_BDCMSGCOLL.

CLEAR: IT_BDCTAB.

endform. " CALL_TRAN

2 REPLIES 2
Read only

Former Member
0 Likes
400

data: n,x,y.

n = 0.

loop at it_data.

n = n + 1.

*logic tomake half records.

x = n / 2.

y = x + 1.

now using the loop at it_data from 1 to x.

write the code for first half.

then loop at it_data from y to n.

write the logic for last half.

reward if useful.

Read only

0 Likes
400

thanks,

at the time i will check the material number also....

pls tell how to check the material number....