Skip to Content
avatar image
Former Member

bdc for vl31n trasaction

Hello guy's

After posting/saving migo doc. i have to run bdc for vl31n inbound deliveries for moment type z01.

depends on recording i found one bdc code but after posting doc. in migo, vl31n took different po quantity .than po quantity .

code is as below.



REPORT zais_inbound_bdc001.
TABLES : lips,lipsd.

DATA :
  vendorno  TYPE likp-lifnr,
  ponumber  TYPE lv50c-bstnr,
  invoiceno TYPE rv50a-verur_la,
*  dlyqty1   TYPE  LIPSD-G_LFIMG.                               " changed by AS 13/06/2017
   itemno TYPE lips-posnr,
   qty TYPE lips-gewei.

DATA:
      t_bdcdata  LIKE TABLE OF bdcdata WITH HEADER LINE.

DATA:
  fs_bdcdata LIKE LINE OF t_bdcdata,   " Structure type of bdcdata
  w_str      TYPE string.
                                        "ON 12/06/2017
*DATA : TQTY TYPE LIKP-BTGEW.                                                " changed by AS 13/06/2017

DATA: BEGIN OF itab OCCURS 0,
        itemno LIKE lips-posnr,
      END OF itab,

      BEGIN OF itab1 OCCURS 0,
        itemno1     LIKE lips-posnr,
        dlyqty1(15) TYPE c,
      END OF itab1,

      BEGIN OF itab2 OCCURS 0,
        dlyqty(15) TYPE c,
      END OF itab2.

DATA: cnt      TYPE i,
      i        LIKE sy-tabix,
      j        LIKE sy-tfill,
      flag(02) TYPE n.

DATA : opt TYPE ctu_params.

opt-defsize    = 'X'.    " Default size for table control
opt-dismode    = 'A'.    " update mode
opt-updmode    = 'S'.     " update mode
*
SPLIT itemno AT ',' INTO TABLE itab.
SPLIT qty    AT ',' INTO TABLE itab2.                                        " changed by AS 13/06/2017
CLEAR :itab,itab2.


LOOP AT itab.
  MOVE itab-itemno TO itab1-itemno1.
  APPEND itab1.
  CLEAR itab1.
ENDLOOP.


*  DESCRIBE TABLE itab1 LINES cnt.
*
*  DO cnt TIMES.
*    LOOP AT itab1.
*      LOOP AT itab2.
*        READ TABLE itab2 INDEX i.
*        READ TABLE itab1 INDEX i.
*        REPLACE ALL OCCURRENCES OF '-1' IN itab2 WITH '0'.
*        MOVE itab2-dlyqty TO itab1-dlyqty1.
*      ENDLOOP.
*    ENDLOOP.
*    i = i + 1.
*    APPEND itab1.
*  ENDDO.




LOOP AT itab1 .
  cnt = sy-tabix.
  READ TABLE itab2 INDEX cnt.
  REPLACE ALL OCCURRENCES OF '-1' IN itab2 WITH '0'.
  itab1-dlyqty1 = itab2-dlyqty.
  MODIFY  itab1 TRANSPORTING dlyqty1.
  CLEAR : itab1,itab2,cnt.
ENDLOOP.


LOOP AT itab1.
  DELETE itab1 WHERE dlyqty1 = ' '.
ENDLOOP.




DATA: datenow(10) TYPE c.
DATA: datec(10) TYPE c.
DATA: fldvar(30) TYPE c.
DATA: fldno TYPE i.


CONCATENATE sy-datum+6(2) '.' sy-datum+4(2) '.' sy-datum+0(4) INTO datenow.
*  CLEAR bdcdata.
*  REFRESH BDCDAT.






PERFORM bdc_dynpro      USING 'SAPMV50A' '4007'.
PERFORM bdc_field       USING 'BDC_CURSOR'                              'LIKP-LIFNR'.
PERFORM bdc_field       USING 'BDC_OKCODE'                              '/00'.
PERFORM bdc_field       USING 'LIKP-LIFNR'                               vendorno.
PERFORM bdc_field       USING 'LV50C-BSTNR'                               ponumber.
PERFORM bdc_field       USING 'RV50A-LFDAT_LA'                             datenow.
PERFORM bdc_field       USING 'RV50A-LFUHR_LA'                              '00:00'.




PERFORM bdc_field       USING 'RV50A-VERUR_LA' invoiceno.


* SECOND SCREEN DATA
PERFORM bdc_dynpro      USING 'SAPMV50A'                                  '1000'.
PERFORM bdc_field       USING 'BDC_OKCODE'                              '=NPAG_T'.
PERFORM bdc_field       USING 'LIKP-BLDAT'                              '02.06.2017'.
PERFORM bdc_field       USING 'BDC_CURSOR'                             'LIPSD-G_LFIMG(01)'.
PERFORM bdc_field       USING 'RV50A-LFDAT_LA'                               datenow.
PERFORM bdc_field       USING 'RV50A-LFUHR_LA'                              '00:00'.
PERFORM bdc_dynpro      USING  'RV50A-LFUHR_LA'	                             '00:00'.




*PERFORM bdc_field       USING  'LIKP-BTGEW'  TQTY.
*PERFORM bdc_field       USING  'LIKP-GEWEI'  qty.                               " changed by AS 13/06/2017
*PERFORM bdc_field       USING  'LIPSD-G_LFIMG(01)'  dlyqty1.


flag  = 1.
DATA c TYPE i VALUE 1.
DESCRIBE TABLE itab1 LINES c.




LOOP AT itab1.
  CONDENSE itab1-dlyqty1.


  CONCATENATE 'LIPSD-G_LFIMG(' flag ')' INTO fldvar.
  PERFORM bdc_field    USING fldvar itab1-dlyqty1.
  flag  = flag  + 1.


  IF flag EQ 9.
    PERFORM bdc_dynpro      USING 'SAPMV50A'                                '1000'.
    PERFORM bdc_field       USING 'BDC_OKCODE'                              '=NPAG_T'.
    PERFORM bdc_field       USING 'LIKP-BLDAT'                               datenow.
    PERFORM bdc_field       USING 'RV50A-LFDAT_LA'                           datenow .
    PERFORM bdc_field       USING 'RV50A-LFUHR_LA'                            '00:00'.
    c = c - 8 .
    IF     c = 1.
      flag = 8.
    ELSEIF c = 2.
      flag = 7.
    ELSEIF c = 3.
      flag = 6.
    ELSEIF c = 4.
      flag = 5.
    ELSEIF c = 5.
      flag = 4.
    ELSEIF c = 6.
      flag = 3.
    ELSEIF c = 7.
      flag = 2.
    ELSE .
      flag = 1.
    ENDIF.
  ENDIF.
  CLEAR itab1.
ENDLOOP.


*===============    deleting line items of the  table control whose quantity is Zero *


flag = 1.


cnt = 0.


DESCRIBE TABLE  itab1 LINES c.
         
PERFORM bdc_dynpro      USING 'SAPMV50A'                                    '1000'.
PERFORM bdc_field       USING 'BDC_OKCODE'                                 'FPAG_T'.
PERFORM bdc_field       USING 'RV50A-LFDAT_LA'                              datenow .
PERFORM bdc_field       USING 'RV50A-LFUHR_LA'                              '00:00'.


LOOP AT itab1.


*    IF c > 13 .
  IF flag EQ 09 .


    PERFORM bdc_dynpro      USING 'SAPMV50A'                                 '1000'.
    PERFORM bdc_field       USING 'BDC_OKCODE'                              'NPAG_T'.
    PERFORM bdc_field       USING 'RV50A-LFDAT_LA'                           datenow .
    PERFORM bdc_field       USING 'RV50A-LFUHR_LA'                           '00:00'.
    c = c - 8.
    cnt = cnt + 1.
    IF c = 1.
      flag = 8.
    ELSEIF c = 2.
      flag = 7.
    ELSEIF c = 3.
      flag = 6.
    ELSEIF c = 4.
      flag = 5.
    ELSEIF c = 5.
      flag = 4.
    ELSEIF c = 6.
      flag = 3.
    ELSEIF c = 7.
      flag = 2.
    ELSE .
      flag = 1.
    ENDIF.
  ENDIF.


  IF itab1-dlyqty1 EQ '0' .
    CLEAR fldvar.


    DO cnt TIMES .
      PERFORM bdc_dynpro      USING 'SAPMV50A'         '1000'.
      PERFORM bdc_field       USING 'BDC_OKCODE'       'NPAG_T'.
      PERFORM bdc_field       USING 'RV50A-LFDAT_LA'    datenow .
      PERFORM bdc_field       USING 'RV50A-LFUHR_LA'   '00:00'.
    ENDDO.
    CONCATENATE 'RV50A-LIPS_SELKZ(' flag ')'INTO fldvar.


    PERFORM bdc_dynpro      USING 'SAPMV50A'           '1000'.
    PERFORM bdc_field       USING fldvar 'X' .
    PERFORM bdc_field       USING 'BDC_OKCODE'         '=POLO_T'.
    PERFORM bdc_field       USING 'BDC_SUBSCR'         'SAPMV50A'.
    c = c - 1.
  ELSE.
    flag = flag + 1.
  ENDIF.
  CLEAR itab1.
ENDLOOP.


PERFORM bdc_dynpro      USING 'SAPMV50A' '1000'.
PERFORM bdc_field       USING 'BDC_OKCODE'                               'SICH_T'.
PERFORM bdc_field       USING 'LIKP-BLDAT'       datenow.
PERFORM bdc_field       USING 'RV50A-LFDAT_LA'   datenow.
PERFORM bdc_field       USING 'RV50A-LFUHR_LA'                            '00:00'.




DATA:
  t_msg      TYPE TABLE OF bdcmsgcoll WITH HEADER LINE,
  w_msg      TYPE TABLE OF bdcmsgcoll WITH HEADER LINE,
  w_msg1(51).




CALL TRANSACTION 'VL31N'
                          USING t_bdcdata
                          OPTIONS  FROM opt
                          MESSAGES INTO t_msg.


CLEAR t_bdcdata.
REFRESH t_bdcdata.


IF sy-subrc EQ 0.
  WRITE :/ 'Data Uploaded to database.'.




  LOOP AT t_msg .
    MOVE: t_msg-msgid TO w_msg-msgid,
          t_msg-msgnr TO w_msg-msgnr,
          t_msg-msgv1 TO w_msg-msgv1,
          t_msg-msgv2 TO w_msg-msgv2,
          t_msg-msgv3 TO w_msg-msgv3,
          t_msg-msgv4 TO w_msg-msgv4.
    APPEND w_msg.
  ENDLOOP.
  CLEAR t_msg..
  CLEAR w_msg.


  LOOP AT w_msg.
    SELECT SINGLE text FROM t100
      INTO w_msg-msgv1
      WHERE msgnr EQ  w_msg-msgnr AND arbgb EQ  w_msg-msgid
      AND sprsl EQ sy-langu.


    MODIFY  w_msg.


  ENDLOOP.
ENDIF.








INCLUDE zais_inbound_bdc001_bdc_dynf01.
*&---------------------------------------------------------------------*
*&      Form  BDC_FIELD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0199   text
*      -->P_0200   text
*----------------------------------------------------------------------*
FORM bdc_field  USING fnam fval.


  IF NOT fval IS INITIAL.


    CLEAR t_bdcdata.


    t_bdcdata-fnam = fnam.


    t_bdcdata-fval = fval.


    APPEND t_bdcdata.


  ENDIF.
ENDFORM.
<br>

Thanks & Regards

Aniket

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers