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

bdc program

Former Member
0 Likes
597

hi all,

i am uploading data to ml10 transaction.

its for multiple line items, activityno and and quantity are multiple line items here.

i developed the code.

my input file

230.1|serv|TEST|SEARCH|INR|0003|cg01|COL-JAL 10 1.4|100

230.1|serv|TEST|SEARCH|INR|0003|cg01|COL-JAL 10 1.3|100

wen i give this its working fine,and uploading multiple line items also.

but wen i give

my input file

230.1|serv|TEST|SEARCH|INR|0003|cg01|COL-JAL 10 1.4|100

230.1|serv|TEST|SEARCH|INR|0003|cg01|COL-JAL 10 1.3|100

232.1|serv|TEST|SEARCH|INR|0003|cg01|COL-JAL 10 1.4|100

232.1|serv|TEST|SEARCH|INR|0003|cg01|COL-JAL 10 1.3|100

that is wen i give the new modal specification number 232.1

it saying 230.1 already existing.

its is uploading well under same model specification number(multiple items too)but wen i go for new model specification number it is giving problem

can any body help me in this regard.

TYPES: BEGIN OF TY_FLAT, " structure for flat file

STRING(200),

END OF TY_FLAT.

TYPES: BEGIN OF TY_HEAD, " structure for header file

IND(2) TYPE N,

SPEC_NO(10),

ASTYP(4),

TXZ01(40),

SORT1(20),

WAERS(5),

MATKL(9),

EKORG(4),

END OF TY_HEAD.

TYPES :BEGIN OF TY_ITEM, "structure for item file

IND(2) TYPE N,

SRVPOS(18),

MENGE(13),

END OF TY_ITEM.

TYPES :BEGIN OF TY_FLAT1, " structure for final file

SPEC_NO(10),

ASTYP(4),

TXZ01(40),

SORT1(20),

WAERS(5),

MATKL(9),

EKORG(4),

SRVPOS(18),

MENGE(13),

END OF TY_FLAT1.

----


  • INTERNAL TABLE DECLARATIONS *

----


DATA : T_FLAT TYPE STANDARD TABLE OF TY_FLAT,

T_FLAT1 TYPE STANDARD TABLE OF TY_FLAT1,

T_HEAD TYPE STANDARD TABLE OF TY_HEAD,

T_ITEM TYPE STANDARD TABLE OF TY_ITEM,

T_BDCDATA TYPE STANDARD TABLE OF BDCDATA,

T_BDCMSG TYPE STANDARD TABLE OF BDCMSGCOLL.

----


  • WORK AREA DECLARATIONS *

----


DATA : ST_FLAT TYPE TY_FLAT,

ST_FLAT1 TYPE TY_FLAT1,

ST_HEAD TYPE TY_HEAD,

ST_ITEM TYPE TY_ITEM,

ST_BDCDATA TYPE BDCDATA,

ST_BDCMSG TYPE BDCMSGCOLL.

----


  • VARIABLES *

----


DATA : FNAM TYPE LOCALFILE, "rlgrap-filename,

FTYP TYPE RLGRAP-FILETYPE,

LF_FNAM TYPE STRING.

----


  • VARIABLES *

----


DATA : V_IND(2) TYPE N, " value 1,

V_FLD(20),

V_NO(2) TYPE N.

----


  • SELECTION SCREEN *

----


SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001. "selection screen

PARAMETERS : P_FNAM LIKE FNAM.

SELECTION-SCREEN : END OF BLOCK B1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAM.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = ' '

IMPORTING

FILE_NAME = P_FNAM.

CALL FUNCTION 'WS_UPLOAD' " uploading flat file

EXPORTING

FILENAME = P_FNAM

FILETYPE = 'ASC'

TABLES

DATA_TAB = T_FLAT.

IF SY-SUBRC NE 0.

WRITE : /1 'no flat file to upload into internal table t_flat'.

LEAVE TO LIST-PROCESSING.

ENDIF.

START-OF-SELECTION.

  • splitting the flat file data into header table and item table

LOOP AT T_FLAT INTO ST_FLAT.

  • ADD 1 TO v_ind.

SPLIT ST_FLAT AT '|' INTO ST_FLAT1-SPEC_NO ST_FLAT1-ASTYP

ST_FLAT1-TXZ01 ST_FLAT1-SORT1

ST_FLAT1-WAERS ST_FLAT1-MATKL

ST_FLAT1-EKORG ST_FLAT1-SRVPOS

ST_FLAT1-MENGE.

APPEND ST_FLAT1 TO T_FLAT1.

CLEAR ST_FLAT1.

ENDLOOP.

SORT T_FLAT1 BY SPEC_NO ASTYP TXZ01 SORT1 WAERS MATKL EKORG.

LOOP AT T_FLAT1 INTO ST_FLAT1.

MOVE :

ST_FLAT1-SPEC_NO TO ST_HEAD-SPEC_NO,

ST_FLAT1-ASTYP TO ST_HEAD-ASTYP,

ST_FLAT1-TXZ01 TO ST_HEAD-TXZ01,

ST_FLAT1-SORT1 TO ST_HEAD-SORT1,

ST_FLAT1-WAERS TO ST_HEAD-WAERS,

ST_FLAT1-MATKL TO ST_HEAD-MATKL,

ST_FLAT1-EKORG TO ST_HEAD-EKORG,

ST_FLAT1-SRVPOS TO ST_ITEM-SRVPOS,

ST_FLAT1-MENGE TO ST_ITEM-MENGE .

AT NEW EKORG.

  • AT end of EKORG.

ADD 1 TO V_IND.

ENDAT.

MOVE V_IND TO ST_HEAD-IND.

MOVE V_IND TO ST_ITEM-IND.

APPEND ST_HEAD TO T_HEAD.

APPEND ST_ITEM TO T_ITEM.

CLEAR ST_HEAD.

CLEAR ST_ITEM.

*CLEAR v_ind.

ENDLOOP.

CLEAR V_IND.

*perform open_group.

SORT T_ITEM BY IND.

SORT T_HEAD BY IND.

DELETE ADJACENT DUPLICATES FROM T_HEAD.

LOOP AT T_HEAD INTO ST_HEAD.

PERFORM BDC_DYNPRO USING 'SAPLMLSM' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'TEMP_SPEC-ASTYP'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'TMP_SPEC-SPEC_NO'

ST_HEAD-SPEC_NO.

PERFORM BDC_FIELD USING 'TMP_SPEC-ASTYP'

ST_HEAD-ASTYP.

PERFORM BDC_DYNPRO USING 'SAPLMLSM' '0200'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'TMP_SPEC-EKORG'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=SRV'.

PERFORM BDC_FIELD USING 'TMP_SPEC-TXZ01'

ST_HEAD-TXZ01.

PERFORM BDC_FIELD USING 'TMP_SPEC-SORT1'

ST_HEAD-SORT1.

PERFORM BDC_FIELD USING 'TMP_SPEC-WAERS'

ST_HEAD-WAERS.

PERFORM BDC_FIELD USING 'TMP_SPEC-MATKL'

ST_HEAD-MATKL.

PERFORM BDC_FIELD USING 'TMP_SPEC-EKORG'

ST_HEAD-EKORG.

LOOP AT T_ITEM INTO ST_ITEM WHERE IND = ST_HEAD-IND.

ADD 1 TO V_NO.

PERFORM BDC_DYNPRO USING 'SAPLMLSP' '0201'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BZE'.

PERFORM BDC_FIELD USING 'BDC_SUBSCR'

'SAPLMLSP'.

PERFORM BDC_DYNPRO USING 'SAPLMLSP' '0201'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BZE'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'ESLL-MENGE(01)'.

CONCATENATE 'ESLL-SRVPOS(' V_NO ')' INTO V_FLD.

CONDENSE V_FLD.

PERFORM BDC_FIELD USING V_FLD

ST_ITEM-SRVPOS.

CONCATENATE 'ESLL-MENGE(' V_NO ')' INTO V_FLD.

CONDENSE V_FLD.

PERFORM BDC_FIELD USING V_FLD

ST_ITEM-MENGE.

*perform bdc_field using 'ESLL-SRVPOS(01)'

  • ITAB_PROGRAM-SRVPOS.

*

*

*perform bdc_field using 'ESLL-MENGE(01)'

  • ITAB_PROGRAM-MENGE.

PERFORM BDC_DYNPRO USING 'SAPLMLSP' '0201'.

V_NO = 1.

ENDLOOP.

CLEAR V_NO.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=SAV'.

PERFORM BDC_FIELD USING 'BDC_SUBSCR'

'SAPLMLSP'.

CALL TRANSACTION 'ML10' USING T_BDCDATA MODE 'A'

UPDATE 'A' MESSAGES INTO T_BDCMSG.

ENDLOOP.

PERFORM FR_FORMAT_MESSAGE.

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR ST_BDCDATA.

ST_BDCDATA-PROGRAM = PROGRAM.

ST_BDCDATA-DYNPRO = DYNPRO.

ST_BDCDATA-DYNBEGIN = 'X'.

APPEND ST_BDCDATA TO T_BDCDATA.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> SPACE. "NODATA.

CLEAR ST_BDCDATA.

ST_BDCDATA-FNAM = FNAM.

ST_BDCDATA-FVAL = FVAL.

APPEND ST_BDCDATA TO T_BDCDATA.

ENDIF.

ENDFORM.

&----


*& Form fr_format_message

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FR_FORMAT_MESSAGE.

DATA : MESSAGE TYPE STRING.

WRITE : /1 'ID',

5 'No',

10 'Type',

20 'Message Info',

55 'Row No'.

LOOP AT T_BDCMSG INTO ST_BDCMSG.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = ST_BDCMSG-MSGID

LANG = SY-LANGU

NO = ST_BDCMSG-MSGNR

V1 = ST_BDCMSG-MSGV1

V2 = ST_BDCMSG-MSGV2

V3 = ST_BDCMSG-MSGV3

V4 = ST_BDCMSG-MSGV4

IMPORTING

MSG = MESSAGE

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2

.

IF SY-SUBRC EQ 0.

WRITE : /1 ST_BDCMSG-MSGID,

5 ST_BDCMSG-MSGNR,

10 ST_BDCMSG-MSGTYP,

20 MESSAGE.

ENDIF.

IF SY-SUBRC NE 0.

WRITE : /55 SY-TABIX.

ENDIF.

ENDLOOP.

ENDFORM. " fr_format_message

thanks in advance

shiva

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
531

Hi,

It is giving error becaseu of error in data of BDC_data.

Solution:

Give commands as :

Refresh t_bdcdata.
clear t_bdcdata.

IMMEDIATLY after call transaction command.

It will work.

Jogdand M B

3 REPLIES 3
Read only

Former Member
0 Likes
532

Hi,

It is giving error becaseu of error in data of BDC_data.

Solution:

Give commands as :

Refresh t_bdcdata.
clear t_bdcdata.

IMMEDIATLY after call transaction command.

It will work.

Jogdand M B

Read only

Former Member
0 Likes
531

Hi Siva.

I think your problem lies in assigning the indicator V_IND. In the loop splitting the flat file you're only changing the indicator if the field ekorg is different. Normally the group processing should work if any of the leading fields would be changing also, but you may have a look in the debugger, if the V_IND is really changed at the 3rd item.


AT NEW EKORG.
* AT end of EKORG.
ADD 1 TO V_IND.
ENDAT.

But in the end you do a loop over all ITEMS that have the same indicator number

LOOP AT T_ITEM INTO ST_ITEM WHERE IND = ST_HEAD-IND.

So the loop seems to select also the two already processed items form your first spec_no.

Hope my hint is somehow helpful,

Timo

Read only

Former Member
0 Likes
531

See two things may be there,

First the record is already there means it will throw the same error...

Its not get cleared when it comes for he next time...

So try to clear the data and try this concept will surely work

Try to reward if useful

dont forget