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: 

I want to know how to use ranges inside a loop when i am using checkboxes.

former_member809080
Participant
0 Kudos

TYPES: BEGIN OF st_vbak,
vbeln TYPE vbeln_va,
erdat TYPE erdat,
erzet TYPE erzet,
ernam TYPE ernam,
angdt TYPE angdt_v,
auart TYPE auart,
END OF st_vbak.

TYPES : BEGIN OF st_vbap,
posnr TYPE posnr_va,
vbeln TYPE vbeln_va,
matnr TYPE matnr,
zmeng TYPE dzmeng,
zieme TYPE dzieme,
werks TYPE werks_ext,
END OF st_vbap .

TYPES: BEGIN OF st_final,
vbeln TYPE vbeln_va,
erdat TYPE erdat ,
erzet TYPE erzet ,
ernam TYPE ernam,
angdt TYPE angdt_v ,
auart TYPE auart ,
posnr TYPE posnr_va,
matnr TYPE matnr,
zmeng TYPE dzmeng ,
zieme TYPE dzieme ,
werks TYPE werks_ext,
CHECK TYPE flag,

END OF ST_FINAL.

DATA: WA_VBAK TYPE ST_VBAK,
WA_VBAP TYPE ST_VBAP,
WA_FINAL TYPE ST_FINAL,
IT_VBAP TYPE TABLE OF ST_VBAP,
IT_VBAK TYPE TABLE OF ST_VBAK,
IT_FINAL TYPE TABLE OF ST_FINAL,


WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_LAYOUT TYPE SLIS_LAYOUT_ALV.


DATA: V_POS TYPE I .






SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_VBELN FOR WA_VBAK-vbeln ,
S_ERDAT FOR WA_VBAK-erdat OBLIGATORY ,
S_WERKS FOR WA_VBAP-werks ,
S_MATNR FOR WA_VBAP-matnr .

SELECTION-SCREEN END OF BLOCK B1.


SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.

PARAMETERS: P_AUART TYPE VBAK-auart .

SELECTION-SCREEN END OF BLOCK B2.


START-OF-SELECTION .

SELECT VBELN
ERDAT
ERZET
ERNAM
ANGDT
AUART FROM VBAK INTO TABLE IT_VBAK
WHERE VBELN IN S_VBELN
AND ERDAT IN S_ERDAT
AND AUART EQ P_AUART.


IF IT_VBAK IS NOT INITIAL .

SELECT POSNR
VBELN
MATNR
ZMENG
ZIEME
WERKS FROM VBAP INTO TABLE IT_VBAP
FOR ALL ENTRIES IN IT_VBAK
WHERE VBELN = IT_VBAK-vbeln
AND WERKS IN S_WERKS
AND MATNR IN S_MATNR.

ENDIF.

LOOP AT IT_VBAP INTO WA_VBAP.
READ TABLE IT_VBAK INTO WA_VBAK WITH KEY VBELN = WA_VBAP-vbeln.
IF SY-SUBRC = 0.
WA_FINAL-VBELN = WA_VBAK-vbeln.
WA_FINAL-erdat = WA_VBAK-erdat.
WA_FINAL-erzet = WA_VBAK-erzet.
WA_FINAL-ernam = WA_VBAK-ernam.
WA_FINAL-angdt = WA_VBAK-angdt.
WA_FINAL-auart = WA_VBAK-auart.
ENDIF.


WA_FINAL-posnr = WA_VBAP-posnr.
WA_FINAL-matnr = WA_VBAP-matnr.
WA_FINAL-zmeng = WA_VBAP-zmeng.
WA_FINAL-zieme = WA_VBAP-zieme.
WA_FINAL-werks = WA_VBAP-werks.

APPEND WA_FINAL TO IT_FINAL.
CLEAR WA_FINAL.
ENDLOOP.



WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'CHECK'.
WA_FIELDCAT-seltext_l = 'CHECK BOX'.
WA_FIELDCAT-checkbox = 'X'.
WA_FIELDCAT-edit = 'X'.



APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.




WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'VBELN'.
WA_FIELDCAT-tabname = 'VBAK'.
WA_FIELDCAT-seltext_l = 'SALES DOCUMENT NUMBER'.
wa_fieldcat-no_zero = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.


WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'ERDAT'.
WA_FIELDCAT-tabname = 'VBAK'.
WA_FIELDCAT-seltext_l = 'SALES DOCUMENT DATE'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.


WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'ERZET'.
WA_FIELDCAT-tabname = 'VBAK'.
WA_FIELDCAT-seltext_l = 'ENTRY TIME'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.


WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'ERNAM'.
WA_FIELDCAT-tabname = 'VBAK'.
WA_FIELDCAT-seltext_l = 'NAME OF PERSON WHO WAS CREATED'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.


WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'AUART'.
WA_FIELDCAT-tabname = 'VBAK'.
WA_FIELDCAT-seltext_l = 'SALES DOCUMENT TYPE'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.


WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'POSNR'.
WA_FIELDCAT-tabname = 'VBAP'.
WA_FIELDCAT-seltext_l = 'SALES DOCUMENT ITEM'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.

WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'WERKS'.
WA_FIELDCAT-tabname = 'VBAP'.
WA_FIELDCAT-seltext_l = 'PLANT'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.


WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'MATNR'.
WA_FIELDCAT-tabname = 'VBAP'.
WA_FIELDCAT-seltext_l = 'MATERIAL NUMBER'.

WA_FIELDCAT-no_zero = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.

WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'ZMENG'.
WA_FIELDCAT-tabname = 'VBAP'.
WA_FIELDCAT-seltext_l = 'TARGET QUANTITY IN SALES UNIT'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.


WA_FIELDCAT-col_pos = V_POS.
V_POS = V_POS + 1 .
WA_FIELDCAT-fieldname = 'ZIEME'.
WA_FIELDCAT-tabname = 'VBAP'.
WA_FIELDCAT-seltext_l = 'TARGET QUNANTITY UOM'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.


WA_LAYOUT-colwidth_optimize = 'X'.
WA_LAYOUT-zebra = 'X'.
WA_LAYOUT-box_fieldname = 'CHECK'.
WA_LAYOUT-box_tabname = 'IT_FINAL'.




CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'INTERACTIVE_USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT

* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = IT_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'ZSTANDARD4'.
ENDFORM.

FORM INTERACTIVE_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.

data: g_grid TYPE REF TO CL_GUI_ALV_GRID.
DATA: LV_REFRESH TYPE FLAG.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
* EXPORTING
* IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
* ET_EXCLUDING =
* E_REPID =
* E_CALLBACK_PROGRAM =
* E_CALLBACK_ROUTINE =
E_GRID = G_GRID
* ET_FIELDCAT_LVC =
* ER_TRACE =
* E_FLG_NO_HTML =
* ES_LAYOUT_KKBLO =
* ES_SEL_HIDE =
* ET_EVENT_EXIT =
* ER_FORM_TOL =
* ER_FORM_EOL =
.

IF G_GRID IS NOT INITIAL.
LV_REFRESH = 'X'.
CALL METHOD g_grid->check_changed_data
* IMPORTING
* e_valid =
CHANGING
c_refresh = LV_REFRESH.
ENDIF.


CASE R_UCOMM.
WHEN 'DISPLAY'.

LOOP AT IT_FINAL INTO WA_FINAL WHERE CHECK = 'X'.

S_MATNR-sign = 'I'.
S_MATNR-option = 'EQ'.
S_MATNR-low = WA_FINAL-matnr.

APPEND S_MATNR .

S_WERKS-sign = 'I'.
S_WERKS-option = 'EQ'.
S_WERKS-low = WA_FINAL-werks.
APPEND S_WERKS .

ENDLOOP.


IF RS_SELFIELD-fieldname = 'CHECK'.
READ TABLE IT_FINAL INTO WA_FINAL WITH KEY check = 'X'.
SUBMIT ZDD_NEW_ALV_2
WITH S_MATNR BETWEEN WA_FINAL-matnr AND WA_FINAL-matnr
WITH S_WERKS BETWEEN WA_FINAL-werks AND WA_FINAL-werks
AND RETURN.
ENDIF.



ENDCASE.


ENDFORM.
3 REPLIES 3

Sandra_Rossi
Active Contributor

Your attempt to format the code failed. Try to paste code inside the code area using Ctrl+Shift+V (unformatted paste).

Sandra_Rossi
Active Contributor

I don't understand your question.

Maybe IN is what you're looking for?

SUBMIT ZDD_NEW_ALV_2
WITH s_matnr IN s_matnr
WITH s_werks IN s_werks AND RETURN.

former_member809080
Participant
0 Kudos

Thanks

for helping me .