Zpo FTP Transfer
Zpo FTP Transfer
Zpo FTP Transfer
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
PROGRAM ZPO_FTP_TRANSFER.
TABLES : nast.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
ent_screen TYPE c .
w_ebeln = nast-OBJKY+0(10).
DATA IT_EKKO TYPE STANDARD TABLE OF EKKO. "internal table
"Vendor
"vendor
"Heder
"Heder
"Item
"Item
"T&C
"T&C
END OF ts_vendor.
END OF ts_header.
END OF ts_item.
END OF ts_tc.
END OF ts_ekpo.
END OF TS_T001W.
END OF TS_KNA1.
P_FILE(50) TYPE C.
TEXT(1000),
END OF TY_TEXT.
END OF lts_result.
END OF TS_ESLL.
SELECT SINGLE *
FROM EKKO
INTO IS_EKKO
IF SY-SUBRC = 0.
REFRESH it_nast.
REFRESH it_ekpo.
SELECT ebeln
EBELP
BANFN
MATNR
TXZ01
MEINS
MENGE
NETPR
PACKNO
werks
loekz
netwr
FROM ekpo
IF sy-subrc eq 0.
REFRESH it_ekpo_temp.
it_ekpo_temp = it_ekpo.
SELECT werks
kunnr
FROM t001w
IF sy-subrc eq 0.
SORT it_t001w by werks.
SELECT kunnr
STCD3
FROM kna1
IF sy-subrc eq 0.
ENDIF.
ENDIF.
ENDIF.
REFRESH it_ekpo_temp.
it_ekpo_temp = it_ekpo.
REFRESH LT_ESLL_T.
SELECT PACKNO
INTROW
EXTROW
SRVPOS
SUB_PACKNO
MENGE
MEINS
NETWR
KTEXT1
MATKL
FROM ESLL
IF SY-SUBRC EQ 0.
REFRESH LT_ESLL.
SELECT PACKNO
INTROW
EXTROW
SRVPOS
SUB_PACKNO
MENGE
MEINS
NETWR
KTEXT1
MATKL
FROM ESLL
IF SY-SUBRC EQ 0.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
SELECT SINGLE *
FROM J_1IMOVEND
INTO IS_J_1IMOVEND
SELECT SINGLE *
FROM LFA1
INTO IS_LFA1
CLEAR is_final.
is_final-Vendor_Legacy_Code = is_ekko-lifnr.
FROM J_1IMOVEND
INTO is_final-uid
is_final-UID_Type = 'PAN'.
is_final-VENDOR_GSTIN = is_lfa1-stcd3.
"build header
is_final-PO_No = is_ekko-ebeln.
CLEAR w_nast.
IF w_nast > 1 .
is_final-PO_Amendment_Flag = 'Yes'.
ELSE.
is_final-PO_Amendment_Flag = 'No'.
ENDIF.
DATE_INTERNAL = is_ekko-bedat
IMPORTING
DATE_EXTERNAL = is_final-PO_Date
EXCEPTIONS
DATE_INTERNAL_IS_INVALID = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
EXPORTING
DATE_INTERNAL = is_ekko-kdatb
IMPORTING
DATE_EXTERNAL = is_final-PO_start_dt
EXCEPTIONS
DATE_INTERNAL_IS_INVALID = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
EXPORTING
DATE_INTERNAL = is_ekko-kdate
IMPORTING
DATE_EXTERNAL = is_final-PO_Expiry_dt
EXCEPTIONS
DATE_INTERNAL_IS_INVALID = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
is_final-Buyer_org_ID = '416'.
INTO is_final-PO_Creator_Name
FROM V_USR_NAME
is_final-PO_Type = is_ekko-bsart.
is_final-PO_Category = 'Default_Cat'.
is_final-PO_Creator_ID = is_ekko-ernam.
EXPORTING
DATE_INTERNAL = sy-datum
IMPORTING
DATE_EXTERNAL = is_final-SAP_PO_REL_DT_TIME
EXCEPTIONS
DATE_INTERNAL_IS_INVALID = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
CONDENSE is_final-SAP_PO_REL_DT_TIME.
CLEAR w_time.
CONDENSE w_time.
is_final-Clause_No = is_ekko-zterm .
FROM t052U
INTO is_final-Clause_Details
CLEAR LS_USER.
SELECT SINGLE *
FROM ZFTP_USERNAME
INTO LS_USER.
CONDENSE LS_USER-path.
G_DPWD = LS_USER-PASSWORD.
P_USER = LS_USER-USER_NAME.
EXPORTING
SOURCELEN = G_DLEN
KEY = C_KEY
IMPORTING
EXPORTING
EXPORTING
IMPORTING
HANDLE = G_DHDL
EXCEPTIONS
NOT_CONNECTED.
IF SY-SUBRC NE 0.
ELSE.
REFRESH lt_result.
CLEAR lw_cmd.
CONCATENATE 'cd /' LS_USER-path '/Outgoing/PO/New' INTO lw_cmd.
EXPORTING
handle = G_DHDL
command = lw_cmd
compress = 'N'
TABLES
DATA = lt_result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
WRITE AT / ls_result-LINE.
ENDLOOP.
REFRESH lt_result.
CLEAR lw_cmd.
EXPORTING
handle = G_DHDL
command = lw_cmd
compress = 'N'
TABLES
DATA = lt_result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
WRITE AT / ls_result-LINE.
ENDLOOP.
REFRESH lt_result.
CLEAR P_FILE.
CONDENSE P_FILE.
REFRESH IT_TEXT[].
CLEAR IS_TEXT.
CONCATENATE
"Item
'Item Code'
'Item Description'
'UOM'
'Quantity'
'Unit Price/Rate'
'Sub Total'
'PR No'
"Item
INTO IS_TEXT SEPARATED BY '@~@'.
CLEAR IS_TEXT.
CLEAR w_PO_Value.
CLEAR is_final_temp.
is_final-Buyer_org_GSTIN = '29AABCM1040N1ZG'.
CLEAR LS_ESLL_T.
READ TABLE LT_ESLL_T INTO LS_ESLL_T WITH KEY PACKNO = is_ekpo-PACKNO BINARY SEARCH.
IF SY-SUBRC EQ 0.
CLEAR LS_ESLL.
READ TABLE LT_ESLL INTO LS_ESLL WITH KEY SUB_PACKNO = LS_ESLL_T-SUB_PACKNO BINARY
SEARCH.
IF SY-SUBRC EQ 0.
is_final_temp-Service_Header_Desc = LS_ESLL-KTEXT1.
ENDIF.
ENDIF.
IF is_ekpo-MATNR IS INITIAL.
is_ekpo-MATNR = '88888888'.
ENDIF.
CONCATENATE is_ekpo-banfn
is_ekpo-ebelp
is_ekpo-matnr
is_final_temp-Item_Description = is_ekpo-txz01.
EXPORTING
INPUT = is_ekpo-meins
LANGUAGE = SY-LANGU
IMPORTING
* LONG_TEXT =
OUTPUT = is_final_temp-UOM
* SHORT_TEXT =
EXCEPTIONS
UNIT_NOT_FOUND =1
OTHERS =2
IF SY-SUBRC <> 0.
ENDIF.
is_final_temp-Quantity = is_ekpo-menge.
is_final_temp-Unit_Price_Rate = is_ekpo-netpr.
is_final_temp-Sub_Total = is_ekpo-netpr.
is_final_temp-PR_No = is_ekpo-banfn.
is_final_temp-po_line_item = is_ekpo-ebelp.
CONCATENATE
is_final_temp-Item_Code
is_final_temp-Item_Description
is_final_temp-UOM
is_final_temp-Quantity
is_final_temp-Unit_Price_Rate
is_final_temp-Sub_Total
is_final_temp-PR_No
is_final_temp-po_line_item
is_final_temp-Service_Header_Desc
CLEAR IS_TEXT.
ENDLOOP.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = G_DHDL
CHARACTER_MODE = 'X'
TABLES
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR =3
OTHERS = 4.
IF SY-SUBRC <> 0.
ELSE.
CLEAR P_FILE.
REFRESH IT_TEXT[].
CONCATENATE
'UID'
'UID Type'
'VENDOR GSTIN'
CLEAR IS_TEXT.
CONCATENATE
is_final-Vendor_Legacy_Code
is_final-Vendor_EPS_Code
is_final-UID
is_final-UID_Type
is_final-VENDOR_GSTIN
CLEAR IS_TEXT.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = G_DHDL
CHARACTER_MODE = 'X'
TABLES
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR =3
OTHERS = 4.
CLEAR P_FILE.
CONDENSE P_FILE.
REFRESH IT_TEXT[].
CONCATENATE
"Heder
'PO No'
'PO Value'
'PO Type'
'PO Category'
'SAP_PO_REL_DT_TIME'
"Heder
CLEAR IS_TEXT.
is_final-PO_Value = w_PO_Value.
ENDIF.
CONCATENATE
is_final-PO_No
is_final-PO_Value
is_final-PO_Amendment_Flag
is_final-PO_Date
is_final-PO_start_dt
is_final-PO_Expiry_dt
is_final-Buyer_org_ID
is_final-Buyer_Org_Name
is_final-PO_Creator_Name
is_final-Buyer_org_GSTIN
is_final-PO_Type
is_final-PO_Category
is_final-PO_Creator_ID
is_final-SAP_PO_REL_DT_TIME
CLEAR IS_TEXT.
EXPORTING
HANDLE = G_DHDL
CHARACTER_MODE = 'X'
TABLES
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR =3
OTHERS = 4.
CLEAR P_FILE.
CONDENSE P_FILE.
REFRESH IT_TEXT[].
CONCATENATE
"T&C
'Clause No'
'Clause Name'
'Clause Details'
"T&C
CLEAR IS_TEXT.
CONCATENATE
is_final-Clause_No
is_final-Clause_Name
is_final-Clause_Details
CLEAR IS_TEXT.
EXPORTING
HANDLE = G_DHDL
CHARACTER_MODE = 'X'
TABLES
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR =3
OTHERS = 4.
ENDIF.
ENDIF.
EXPORTING
HANDLE = G_DHDL.
EXPORTING
DESTINATION = C_DEST
EXCEPTIONS
OTHERS = 1.
ent_retco = 0.