2010 May 31 7:53 AM
Hi
we have to create sales order through BDC using session method but the problem is that, we have to create sales order not more than 300 line item as there is a check on accounting entries of bills of not more than 300 line items.
So how would I create sales order of not more than 300 items from a text files which can containg 500 line items.
2010 Jun 01 6:40 AM
Hi Suchender,
I also had similar requirement as yours. Please find the below logic. It will work for you :
READ TABLE itab.
recs = sy-tfill.
a = recs DIV 300.
b = recs MOD 300.
s1 = 1.
s2 = 300.
DO a TIMES.
sno = sy-index.
CONDENSE sno.
CONCATENATE 'SESSION' sno INTO ses_nam SEPARATED BY '_'.
PERFORM session USING ses_nam s1 s2.
s1 = s1 + 300.
IF sy-index <> a.
s2 = s2 + 300.
ENDIF.
ENDDO.
IF b <> 0.
s2 = s2 + b.
sno = sno + 1.
CONDENSE sno.
CONCATENATE 'SESSION' sno INTO ses_nam SEPARATED BY '_'.
PERFORM session USING ses_nam s1 s2.
ENDIF.
*&---------------------------------------------------------------------*
*& Form session
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->SES_NAM text
* -->S1 text
* -->S2 text
*----------------------------------------------------------------------*
FORM session USING ses_nam s1 s2.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
group = ses_nam
keep = 'X'
user = sy-uname
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.
LOOP AT itab FROM s1 TO s2.
REFRESH bdcdata.
PERFORM mapping.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'MM01'
TABLES
dynprotab = bdcdata.
ENDLOOP.
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. "session
Cheers
VJ
Hi Suchender,
I also had similar requirement as yours. Please find the below logic. It will work for you :
READ TABLE itab.
recs = sy-tfill.
a = recs DIV 300.
b = recs MOD 300.
s1 = 1.
s2 = 300.
DO a TIMES.
sno = sy-index.
CONDENSE sno.
CONCATENATE 'SESSION' sno INTO ses_nam SEPARATED BY '_'.
PERFORM session USING ses_nam s1 s2.
s1 = s1 + 300.
IF sy-index <> a.
s2 = s2 + 300.
ENDIF.
ENDDO.
IF b <> 0.
s2 = s2 + b.
sno = sno + 1.
CONDENSE sno.
CONCATENATE 'SESSION' sno INTO ses_nam SEPARATED BY '_'.
PERFORM session USING ses_nam s1 s2.
ENDIF.
*&---------------------------------------------------------------------*
*& Form session
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->SES_NAM text
* -->S1 text
* -->S2 text
*----------------------------------------------------------------------*
FORM session USING ses_nam s1 s2.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
group = ses_nam
keep = 'X'
user = sy-uname
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.
LOOP AT itab FROM s1 TO s2.
REFRESH bdcdata.
PERFORM mapping.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'MM01'
TABLES
dynprotab = bdcdata.
ENDLOOP.
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. "session
Cheers
VJ
2010 May 31 8:06 AM
Hi,
Its purely business requirement on whether to split the line items at 300 and then create a new sales order...Please check the same with your functional consultant.
Hope this helps
Regards
Shiva
2010 May 31 8:14 AM
I want to know how to do it as all the data is stored in BDC Session than how would i do that.
2010 May 31 8:15 AM
While reading the items put a check before bdc_insert, not to exceed 300 lines and ask your functional consultant what to do incase items are more than 300.
2010 May 31 9:03 AM
Tahnks Arjun
but how can we do that if all the 5000 records have come to BDC Sessions tahn how will we insert only 300 in first time . We have to create 1 sale order for 300 line items and another SO for next 300 line items and so on.
Do we have to call form open group for 300 line items only and again for next 300 items or any other metod is there.
2010 May 31 9:34 AM
Do we have to call form open group for 300 line items only and again for next 300 items or any other metod is there
Yes you have to .
2010 May 31 1:32 PM
find the common field which have same data so that it can come into one sales order by this we can reduce the number of sales orders
2010 Jun 01 6:40 AM
Hi Suchender,
I also had similar requirement as yours. Please find the below logic. It will work for you :
READ TABLE itab.
recs = sy-tfill.
a = recs DIV 300.
b = recs MOD 300.
s1 = 1.
s2 = 300.
DO a TIMES.
sno = sy-index.
CONDENSE sno.
CONCATENATE 'SESSION' sno INTO ses_nam SEPARATED BY '_'.
PERFORM session USING ses_nam s1 s2.
s1 = s1 + 300.
IF sy-index <> a.
s2 = s2 + 300.
ENDIF.
ENDDO.
IF b <> 0.
s2 = s2 + b.
sno = sno + 1.
CONDENSE sno.
CONCATENATE 'SESSION' sno INTO ses_nam SEPARATED BY '_'.
PERFORM session USING ses_nam s1 s2.
ENDIF.
*&---------------------------------------------------------------------*
*& Form session
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->SES_NAM text
* -->S1 text
* -->S2 text
*----------------------------------------------------------------------*
FORM session USING ses_nam s1 s2.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
group = ses_nam
keep = 'X'
user = sy-uname
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.
LOOP AT itab FROM s1 TO s2.
REFRESH bdcdata.
PERFORM mapping.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'MM01'
TABLES
dynprotab = bdcdata.
ENDLOOP.
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. "session
Cheers
VJ
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |