Application Development 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: 

FOR BAKRA UNION

adil_kaleem
Explorer
0 Kudos
98

PLEASE CHECK IT AND CORRECT THE SELECT STATEMENT..

REPORT ZPP_PROD_INTF_AKG NO STANDARD PAGE HEADING LINE-SIZE 255 .

TABLES: AFKO,

JEST,

AUFK.

&--


DECLERATION OF TABLE TYPES--

TYPES: BEGIN OF TY_EXL,

AUFNR TYPE AUFNR, "Order Number

PLNBEZ TYPE AFKO-PLNBEZ, "Material Number

PLNNR TYPE PLNNR, "Routing Number

GAMNG TYPE GAMNG, "Total Order Quantity

GLTRS TYPE AFKO-GLTRS, "Scheduled Finish Date

INACT TYPE INACT, "Release Indicator

FTRMS TYPE AFKO-FTRMS, "Date of Release

AUART TYPE AUART, "Order Type

GETRI TYPE AFKO-GETRI, "Confirmed Order Finish Date

WEMNG TYPE WEMNG, "Delivery Quantity

DISPO TYPE DISPO, "MRP Controller

END OF TY_EXL.

TYPES: BEGIN OF TY_EXL1,

AUFNR(8) TYPE C, "Order Number

PLNBEZ(12) TYPE C, "Material Number

PLNNR(12) TYPE C, "Routing Number

GAMNG(7) TYPE N, "Total Order Quantity

GLTRS TYPE DATS," VALUE 'DD.MM.YY', "Scheduled Finish Date

INACT TYPE C, "Release Indicator

FTRMS TYPE DATS," VALUE 'DD.MM.YY', "Date of Release

AUART(2) TYPE C, "Order Type

GETRI TYPE DATS," VALUE 'DD.MM.YY', "Confirmed Order Finish Date

WEMNG(7) TYPE N, "Delivery Quantity

DISPO(2) TYPE C, "MRP Controller

END OF TY_EXL1.

DATA: IT_EXL TYPE STANDARD TABLE OF TY_EXL INITIAL SIZE 1.

DATA: WA_EXL LIKE LINE OF IT_EXL.

DATA: IT_EXL1 TYPE STANDARD TABLE OF TY_EXL1 INITIAL SIZE 1.

DATA: WA_EXL1 LIKE LINE OF IT_EXL1.

&--


TABLE FOR OBJECT NO,--

DATA: BEGIN OF IT_OBJNR OCCURS 0,

OBJNR TYPE OBJNR,

END OF IT_OBJNR.

DATA: WA_OBJNR LIKE LINE OF IT_OBJNR.

&--


TABLES FOR OPEN ORDERS NO.--

DATA: BEGIN OF IT_AUFNR OCCURS 0,

AUFNR TYPE AUFNR,

END OF IT_AUFNR.

DATA: WA_AUFNR LIKE LINE OF IT_AUFNR.

**********Parameters for TESTRUN AND UPDATE******************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

PARAMETERS: TEST DEFAULT 'X' RADIOBUTTON GROUP g1, "user-command rad1,

UPDATE RADIOBUTTON GROUP g1.

SELECTION-SCREEN END OF BLOCK b1.

&----


*AT SELECTION-SCREEN.

  • Check for radio-button selection

&----


START-OF-SELECTION.

PERFORM ORDNO. "SELECT FOR OPEN ORDER NUMBERS

PERFORM OBJNR. "OBJECT NUMBERS

PERFORM FINSEL. "FINAL POPULATION OF TABLES FOR OPEN ORDER NO.

PERFORM MODIF. "MODIFYING DATA AS PER REQUIREMENT FOR.CSV FILE

&----


*END-OF-SELECTION.

IF TEST = 'X'.

PERFORM TESTRUN.

ELSE.

PERFORM UPDATE.

ENDIF.

&----


*& Form ORDNO

&----


  • SELECTING THE OPEN ORDER NUMBERS

----


  • --> p1 text

  • <-- p2 text

----


form ORDNO .

SELECT * FROM AFKO. "TOP SELECT

&----SELECTING ORDER NO. FROM PLANT '5301' AND TYPE 'AKGN'--


SELECT SINGLE * FROM AUFK WHERE AUFNR = AFKO-AUFNR

AND OBJNR = JEST-OBJNR

AND WERKS = '5301'

AND AUART = 'AKGN'.

&--


SELECTING FOR OPEN PRODUCTION ORDERS--

SELECT SINGLE OBJNR FROM JEST INTO CORRESPONDING FIELDS

OF WA_OBJNR

WHERE OBJNR = AUFK-OBJNR

AND STAT = 'I0045'

AND INACT = 'X'.

APPEND WA_OBJNR TO IT_OBJNR.

                  • SELECTION FOR RELEASE INDICATOR **********************************

SELECT INACT FROM JEST INTO CORRESPONDING FIELDS OF WA_EXL

WHERE OBJNR = WA_OBJNR-OBJNR

AND STAT = 'I0002'

AND INACT = 'X'.

APPEND WA_EXL TO IT_EXL.

ENDSELECT.

&----


ENDSELECT. "END OF TOP SELECT

endform. " ORDNO

&----


*& Form OBJNR

&----


  • SELECTING THE ORDERNO FOR THE OBJECT NUMBERS

----


  • --> p1 text

  • <-- p2 text

----


form OBJNR .

&--


TO GET REQUIRED ORDER NUMBERS--

LOOP AT IT_OBJNR INTO WA_OBJNR.

*WRITE:/ WA_OBJNR-OBJNR. "NO OBJECT NUMBERS FOUND ***

SELECT AUFNR FROM AUFK INTO CORRESPONDING FIELDS OF

WA_AUFNR WHERE OBJNR = WA_OBJNR-OBJNR.

&----


APPEND WA_AUFNR TO IT_AUFNR.

ENDSELECT.

IF SY-SUBRC <> 0.

MESSAGE ' NO OPEN PRODUCTION ORDERS FOUND ' TYPE 'I'.

  • EXIT.

LEAVE LIST-PROCESSING.

ENDIF.

ENDLOOP.

endform. " OBJNR

&----


*& Form FINSEL

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form FINSEL .

&--


LOOPING AT OPEN ORDER NO.FOR FINAL SELECTION--

LOOP AT IT_AUFNR INTO WA_AUFNR.

CHECK NOT IT_AUFNR[] IS INITIAL.

SELECT AUFNR

PLNBEZ

PLNNR

GAMNG

GLTRS

FTRMS

GETRI

DISPO FROM AFKO INTO CORRESPONDING FIELDS OF TABLE IT_EXL

WHERE AUFNR = WA_AUFNR-AUFNR.

SELECT AUART FROM AUFK INTO CORRESPONDING FIELDS OF TABLE IT_EXL

WHERE AUFNR = WA_AUFNR-AUFNR

AND AUART = 'AKGN'.

SELECT WEMNG FROM AFPO INTO CORRESPONDING FIELDS OF TABLE IT_EXL

WHERE AUFNR = WA_AUFNR.

ENDLOOP.

endform. " FINSEL

&----


*& Form MODIF

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form MODIF .

LOOP AT IT_EXL INTO WA_EXL.

WA_EXL1-AUFNR = WA_EXL-AUFNR+4(8).

WA_EXL1-PLNBEZ = WA_EXL-PLNBEZ+6(12).

WA_EXL1-PLNNR = WA_EXL-PLNNR.

WA_EXL1-GAMNG = WA_EXL-GAMNG.

WA_EXL1-GLTRS = WA_EXL-GLTRS.

WA_EXL1-INACT = WA_EXL-INACT.

WA_EXL1-FTRMS = WA_EXL-FTRMS.

WA_EXL1-AUART = WA_EXL-AUART+2(2).

WA_EXL1-GETRI = WA_EXL-GETRI.

WA_EXL1-WEMNG = WA_EXL-WEMNG.

WA_EXL1-DISPO = WA_EXL-DISPO+1(2).

APPEND WA_EXL1 TO IT_EXL1.

ENDLOOP.

endform. " MODIF

&----


*& Form TESTRUN

&----


  • TEST RUN FOR DATA CHECK

----


  • --> p1 text

  • <-- p2 text

----


form TESTRUN .

LOOP AT IT_EXL INTO WA_EXL.

WRITE:/ WA_EXL-AUFNR, WA_EXL-PLNBEZ, WA_EXL-PLNNR, WA_EXL-GAMNG,

WA_EXL-GLTRS, WA_EXL-INACT, WA_EXL-FTRMS, WA_EXL-AUART,

WA_EXL-GETRI, WA_EXL-WEMNG, WA_EXL-DISPO.

ENDLOOP.

endform. " TESTRUN

&----


*& Form UPDATE

&----


  • TO GENERATE $ DELIMIT FILE

----


  • --> p1 text

  • <-- p2 text

----


form UPDATE .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = 'C:\ORDNO.XLS'

FILETYPE = 'ASC'

  • APPEND = ' '

WRITE_FIELD_SEPARATOR = '$'

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • IMPORTING

  • FILELENGTH =

tables

data_tab = IT_EXL1

  • EXCEPTIONS

  • FILE_WRITE_ERROR = 1

  • NO_BATCH = 2

  • GUI_REFUSE_FILETRANSFER = 3

  • INVALID_TYPE = 4

  • NO_AUTHORITY = 5

  • UNKNOWN_ERROR = 6

  • HEADER_NOT_ALLOWED = 7

  • SEPARATOR_NOT_ALLOWED = 8

  • FILESIZE_NOT_ALLOWED = 9

  • HEADER_TOO_LONG = 10

  • DP_ERROR_CREATE = 11

  • DP_ERROR_SEND = 12

  • DP_ERROR_WRITE = 13

  • UNKNOWN_DP_ERROR = 14

  • ACCESS_DENIED = 15

  • DP_OUT_OF_MEMORY = 16

  • DISK_FULL = 17

  • DP_TIMEOUT = 18

  • FILE_NOT_FOUND = 19

  • DATAPROVIDER_EXCEPTION = 20

  • CONTROL_FLUSH_ERROR = 21

  • OTHERS = 22

.

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. " UPDATE

1 ACCEPTED SOLUTION

Former Member
0 Kudos
48
    SELECT SINGLE * FROM aufk WHERE aufnr = afko-aufnr
    AND objnr = <b>jest-objnr</b>
    AND werks = '5301'
    AND auart = 'AKGN'.

Where is jest-objnr set?

Rob

3 REPLIES 3

Former Member
0 Kudos
49
    SELECT SINGLE * FROM aufk WHERE aufnr = afko-aufnr
    AND objnr = <b>jest-objnr</b>
    AND werks = '5301'
    AND auart = 'AKGN'.

Where is jest-objnr set?

Rob

0 Kudos
48

Thank rob, please sujjest the actual code to be there.

0 Kudos
48

This isn't efficient, but baybe it's a start:

SELECT objnr
  FROM jest
  INTO CORRESPONDING FIELDS OF TABLE it_objnr
  WHERE stat = 'I0045'
    AND inact = 'X'.

LOOP AT it_objnr INTO wa_objnr.
  itab_index = sy-tabix.
  SELECT SINGLE *
    FROM aufk
    WHERE objnr = wa_objnr.
  IF sy-subrc <> 0.
    DELETE it_objnr INDEX itab_index.
  ENDIF.
ENDLOOP.

Rob