There is a function, a bunch of bugs, Bdc directly
perform frm_bdc_init.
perform frm_bdc_dynnr using 'SAPML04I' '1001'.
perform frm_bdc_field using space 'LINK-LGNUM' gt_detail-lgnum.
perform frm_bdc_field using space 'LINK-LGTYP' '919'.
perform frm_bdc_field using space 'LINK-PDATU' sy-datum.
perform frm_bdc_field using space 'LINK-IRNUM' gt_detail-zpdno.
perform frm_bdc_field using space 'BDC_OKCODE' '/00'.
perform frm_bdc_dynnr using 'SAPML04I' '1021'.
loop at gt_detail where zpdno = l_zpdno and werks = l_werks and zykmg > 0 and ivnum is initial
and ivnum is initial.
lv_count = lv_count + 1.
*Page turn
if lv_count > 15.
perform frm_bdc_field using space 'BDC_OKCODE' '=P+'.
lv_count = 1.
perform frm_bdc_dynnr using 'SAPML04I' '1021'.
endif.
lv_fname = 'LINP-LGPLA(' && lv_count && ')'.
lv_value = gt_detail-lgort && gt_detail-grtxt.
perform frm_bdc_field using space lv_fname lv_value.
data(lv_li01n) ='X'. "LI01N was executed
endloop.
perform frm_bdc_field using space 'BDC_OKCODE' 'AK'. "激活
if lv_li01n = 'X'.
perform frm_bdc_call using 'LI01N' 'L4' '046' changing lv_rtype lv_rtmsg.
read table gt_messtab with key msgid = 'L4' msgnr = '046'.
if sy-subrc = 0.
data (lv_ivnum) = gt_messtab-msgv1.
endif.